CREATE DATABASE
Creates a new database.
Syntax
CREATE DATABASE database_name [ WITH ] [ OWNER [=] db_owner ] [ CONNECTION LIMIT { limit | UNLIMITED } ]
Parameters
- database_name
-
Name of the new database. For more information about valid names, see Names and Identifiers.
- WITH
-
Optional keyword.
- OWNER
-
Specifies a database owner.
- =
-
Optional character.
- db_owner
-
Username for the database owner.
- CONNECTION LIMIT { limit | UNLIMITED }
-
The maximum number of database connections users are permitted to have open concurrently. The limit is not enforced for super users. Use the UNLIMITED keyword to permit the maximum number of concurrent connections. The limit of concurrent connections for each cluster is 500. A limit on the number of connections for each user might also apply. For more information, see CREATE USER. The default is UNLIMITED. To view current connections, query the STV_SESSIONS system view.
Note
If both user and database connection limits apply, an unused connection slot must be available that is within both limits when a user attempts to connect.
CREATE DATABASE Limits
Amazon Redshift enforces these limits for databases.
-
Maximum of 60 user-defined databases per cluster.
-
Maximum of 127 bytes for a database name.
-
Cannot be a reserved word.
Examples
The following example creates a database named TICKIT and gives ownership to the user DWUSER:
create database tickit with owner dwuser;
Query the PG_DATABASE_INFO catalog table to view details about databases.
select datname, datdba, datconnlimit from pg_database_info where datdba > 1; datname | datdba | datconnlimit -------------+--------+------------- admin | 100 | UNLIMITED reports | 100 | 100 tickit | 100 | 100