CREATEDBSection: PostgreSQL Client Applications (1)Updated: 2003-11-02 |
CREATEDBSection: PostgreSQL Client Applications (1)Updated: 2003-11-02 |
createdb [ option... ] [ dbname ] [ description ]
createdb creates a new PostgreSQL database.
Normally, the database user who executes this command becomes the owner of the new database. However a different owner can be specified via the -O option, if the executing user has appropriate privileges.
createdb is a wrapper around the SQL command CREATE DATABASE [create_database(7)]. There is no effective difference between creating databases via this utility and via other methods for accessing the server.
createdb accepts the following command-line arguments:
The options -D, -E, -O, and -T correspond to options of the underlying SQL command CREATE DATABASE [create_database(7)]; see there for more information about them.
createdb also accepts the following command-line arguments for connection parameters:
In case of difficulty, see CREATE DATABASE [create_database(7)] and psql(1) for discussions of potential problems and error messages. The database server must be running at the targeted host. Also, any default connection settings and environment variables used by the libpq front-end library will apply.
To create the database demo using the default database server:
$ createdb demo CREATE DATABASEThe response is the same as you would have gotten from running the CREATE DATABASE SQL command.
To create the database demo using the server on host eden, port 5000, using the LATIN1 encoding scheme with a look at the underlying command:
$ createdb -p 5000 -h eden -E LATIN1 -e demo CREATE DATABASE "demo" WITH ENCODING = 'LATIN1' CREATE DATABASE