Postgres DB Creation
Show databases
Show databases
psql postgres
\l
\q
Database Creation
Database Creation
CREATE DATABASE
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
Additional options
CREATE DATABASE testdb ENCODING 'utf-8';
createdb
createdb
Runs from the command line rather than psql (or other client)
Database Drop
Database Drop
DROP DATABASE IF EXISTS name
Templates
Templates
If you list databases in a fresh instance you will see three databases:
postgres
template0
template1
By default, a new database will be created by cloning template1.
Bibliography
Bibliography