Skip to main content

CREATE DATABASE

Creates a database.


Syntax

CREATE DATABASE <name>

Description

To create a database, you must have the CREATEDB privilege. You own the databases that you create, by default.

CREATE DATABASE cannot be run in a transaction block.

If you encounter an error and the error message states "could not initialize database directory", possible causes include insufficient permissions on the data directory, insufficient disk space, or a file system error.


Parameters

<name>: the name of the database.


Examples

Create a database named mydb:

CREATE DATABASE mydb;

SQL standard compatibility

The SQL standard does not support CREATE DATABASE.