Although the site administrator is responsible for overall management of the PostgreSQL installation, some databases within the installation may be managed by another person, designated the database administrator. This assignment of responsibilities occurs when a database is created. A user may be assigned explicit privileges to create databases and/or to create new users. A user assigned both privileges can perform most administrative tasks within PostgreSQL, but will not by default have the same operating system privileges as the site administrator.
The Administrator's Guide covers these topics in more detail.
Databases are created by the CREATE DATABASE command issued from within PostgreSQL. createdb is a shell script provided to give the same functionality from the Unix command line.
The PostgreSQL backend must be running for either method to succeed, and the user issuing the command must be the PostgreSQL superuser or have been assigned database creation privileges by the superuser.
To create a new database named mydb from the command line, type
% createdb mydb
and to do the same from within psql type
=> CREATE DATABASE mydb;
If you do not have the privileges required to create a database, you will see the following:
ERROR: CREATE DATABASE: Permission denied.
You automatically become the database administrator of the database you just created. Database names must have an alphabetic first character and are limited to 31 characters in length. PostgreSQL allows you to create any number of databases at a given site.
The Administrator's Guide discusses database creation in more detail, including advanced options of the CREATE DATABASE command.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.