Postgres DB Creation

Show databases

psql postgres

\l

\q

Database Creation

CREATE DATABASE

psql postgres

CREATE DATABASE testdb;

\q

You can the reconnect as the new database...

psql testdb

or simply switch to it before logging out...

\c testdb

Additional options

CREATE DATABASE testdb ENCODING 'utf-8';

createdb

Runs from the command line rather than psql (or other client)

Database Drop

DROP DATABASE IF EXISTS name

Templates

If you list databases in a fresh instance you will see three databases:

By default, a new database will be created by cloning template1.

Bibliography