On this page  
  
  
The CREATE DATABASE statement creates a new CockroachDB database.
Note:
This statement performs a schema change. For more information about how online schema changes work in CockroachDB, see Online Schema Changes.
Required privileges
To create a database, the user must be a member of the admin role or must have the CREATEDB parameter set.
Synopsis
Parameters
| Parameter | Description | 
|---|---|
| IF NOT EXISTS | Create a new database only if a database of the same name does not already exist; if one does exist, do not return an error. | 
| name | The name of the database to create, which must be unique and follow these identifier rules. | 
| encoding | The CREATE DATABASEstatement accepts an optionalENCODINGclause for compatibility with PostgreSQL, butUTF-8is the only supported encoding. The aliasesUTF8andUNICODEare also accepted. Values should be enclosed in single quotes and are case-insensitive.Example: CREATE DATABASE bank ENCODING = 'UTF-8'. | 
| CONNECTION LIMIT | New in v20.2: Supported for compatibility with PostgreSQL. A value of -1indicates no connection limit. Values other than-1are currently not supported. By default,CONNECTION LIMIT = -1. | 
Example
Create a database
> CREATE DATABASE bank;
> SHOW DATABASES;
+---------------+
| database_name |
+---------------+
| bank          |
| defaultdb     |
| postgres      |
| system        |
+---------------+
(4 rows)
Create fails (name already in use)
> CREATE DATABASE bank;
pq: database "bank" already exists
> CREATE DATABASE IF NOT EXISTS bank;
SQL does not generate an error, but instead responds CREATE DATABASE even though a new database wasn't created.
> SHOW DATABASES;
+---------------+
| database_name |
+---------------+
| bank          |
| defaultdb     |
| postgres      |
| system        |
+---------------+
(4 rows)