.\\" auto-generated by docbook2man-spec $Revision: 1.25 $ .TH "CREATEDB" "1" "2002-11-22" "Application" "PostgreSQL Client Applications" .SH NAME createdb \- create a new PostgreSQL database .SH SYNOPSIS .sp \fBcreatedb\fR\fR [ \fR\fB\fIoptions\fB\fR...\fB \fR\fR]\fR\fR [ \fR\fB\fIdbname\fB \fR\fR]\fR\fR [ \fR\fB\fIdescription\fB \fR\fR]\fR .SH "DESCRIPTION" .PP \fBcreatedb\fR creates a new PostgreSQL database. .PP Normally, the database user who executes this command becomes the owner of the new database. However a different owner can be specified via the \fB-O\fR option, if the executing user has appropriate privileges. .PP \fBcreatedb\fR is a shell script wrapper around the SQL command CREATE DATABASE [\fBcreate_database\fR(7)] via the PostgreSQL interactive terminal \fBpsql\fR(1). Thus, there is nothing special about creating databases via this or other methods. This means that the \fBpsql\fR program must be found by the script and that a database server must be running at the targeted port. Also, any default settings and environment variables available to \fBpsql\fR and the \fBlibpq\fR front-end library will apply. .SH "OPTIONS" .PP \fBcreatedb\fR accepts the following command-line arguments: .TP \fB\fIdbname\fB\fR Specifies the name of the database to be created. The name must be unique among all PostgreSQL databases in this installation. The default is to create a database with the same name as the current system user. .TP \fB\fIdescription\fB\fR This optionally specifies a comment to be associated with the newly created database. .TP \fB-D \fIlocation\fB\fR .TP \fB--location \fIlocation\fB\fR Specifies the alternative location for the database. See also \fBinitlocation\fR(1). .TP \fB-e\fR .TP \fB--echo\fR Echo the queries that \fBcreatedb\fR generates and sends to the server. .TP \fB-E \fIencoding\fB\fR .TP \fB--encoding \fIencoding\fB\fR Specifies the character encoding scheme to be used in this database. .TP \fB-O \fIowner\fB\fR .TP \fB--owner \fIowner\fB\fR Specifies the database user who will own the new database. .TP \fB-q\fR .TP \fB--quiet\fR Do not display a response. .TP \fB-T \fItemplate\fB\fR .TP \fB--template \fItemplate\fB\fR Specifies the template database from which to build this database. .PP .PP The options \fB-D\fR, \fB-E\fR, \fB-O\fR, and \fB-T\fR correspond to options of the underlying SQL command CREATE DATABASE [\fBcreate_database\fR(7)]; see there for more information about them. .PP \fBcreatedb\fR also accepts the following command-line arguments for connection parameters: .TP \fB-h \fIhost\fB\fR .TP \fB--host \fIhost\fB\fR Specifies the host name of the machine on which the server is running. If host begins with a slash, it is used as the directory for the Unix domain socket. .TP \fB-p \fIport\fB\fR .TP \fB--port \fIport\fB\fR Specifies the Internet TCP/IP port or the local Unix domain socket file extension on which the server is listening for connections. .TP \fB-U \fIusername\fB\fR .TP \fB--username \fIusername\fB\fR User name to connect as .TP \fB-W\fR .TP \fB--password\fR Force password prompt. .PP .SH "DIAGNOSTICS" .TP \fBCREATE DATABASE\fR The database was successfully created. .TP \fBcreatedb: Database creation failed.\fR (Says it all.) .TP \fBcreatedb: Comment creation failed. (Database was created.)\fR The comment/description for the database could not be created. The database itself will have been created already. You can use the SQL command \fBCOMMENT ON DATABASE\fR to create the comment later on. .PP If there is an error condition, the backend error message will be displayed. See CREATE DATABASE [\fBcreate_database\fR(7)] and \fBpsql\fR(1) for possibilities. .PP .SH "ENVIRONMENT" .TP \fBPGDATABASE\fR If set, the name of the database to create, unless overridden on the command line. .TP \fBPGHOST\fR .TP \fBPGPORT\fR .TP \fBPGUSER\fR Default connection parameters. \fBPGUSER\fR also determines the name of the database to create, if it is not specified on the command line or by \fBPGDATABASE\fR. .SH "EXAMPLES" .PP To create the database demo using the default database server: .sp .nf $ \fBcreatedb demo\fR CREATE DATABASE .sp .fi The response is the same as you would have gotten from running the \fBCREATE DATABASE\fR SQL command. .PP To create the database demo using the server on host eden, port 5000, using the LATIN1 encoding scheme with a look at the underlying query: .sp .nf $ \fBcreatedb -p 5000 -h eden -E LATIN1 -e demo\fR CREATE DATABASE "demo" WITH ENCODING = 'LATIN1' CREATE DATABASE .sp .fi .SH "SEE ALSO" \fBdropdb\fR(1), CREATE DATABASE [\fBcreate_database\fR(7)]