CREATE DATABASE -- Creates a new database
CREATE DATABASE name [ WITH LOCATION = 'dbpath ' ]
CREATE DATABASE creates a new Postgres database. The creator becomes the owner of the new database.
An alternate location can be specified in order to, for example, store the database on a different disk. The path must have been prepared with the initlocation command.
If the path contains a slash, the leading part is interpreted as an environment variable, which must be known to the server process. This way the database administrator can exercise control over at which locations databases can be created. (A customary choice is, e.g., 'PGDATA2'.) If the server is compiled with ALLOW_ABSOLUTE_DBPATHS (not so by default), absolute path names, as identified by a leading slash (e.g., '/usr/local/pgsql/data'), are allowed as well.
CREATE DATABASE is a Postgres language extension.
Use DROP DATABASE to remove a database.
The program createdb is a shell script wrapper around this command, provided for convenience.
There are security and data integrity issues involved with using alternate database locations specified with absolute path names, and by default only an environment variable known to the backend may be specified for an alternate location. See the Administrator's Guide for more information.
To create a new database:
olly=> create database lusiadas;
To create a new database in an alternate area /private_db:
$ mkdir private_db
$ initlocation /private_db
Creating Postgres database system directory /home/olly/private_db/base:
$ psql olly
Welcome to psql, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
olly=> CREATE DATABASE elsewhere WITH LOCATION = '/home/olly/private_db';
CREATE DATABASE
There is no CREATE DATABASE statement in SQL92. Databases are equivalent to catalogs whose creation is implementation-defined.