3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "CREATEDB" "1" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 createdb \- create a new PostgreSQL database
33 .HP \w'\fBcreatedb\fR\ 'u
34 \fBcreatedb\fR [\fIconnection\-option\fR...] [\fIoption\fR...] [\fIdbname\fR\ [\fIdescription\fR]]
42 Normally, the database user who executes this command becomes the owner of the new database\&. However, a different owner can be specified via the
44 option, if the executing user has appropriate privileges\&.
47 is a wrapper around the
50 \fBCREATE DATABASE\fR\&. There is no effective difference between creating databases via this utility and via other methods for accessing the server\&.
54 accepts the following command\-line arguments:
58 Specifies the name of the database to be created\&. The name must be unique among all
60 databases in this cluster\&. The default is to create a database with the same name as the current system user\&.
65 Specifies a comment to be associated with the newly created database\&.
68 \fB\-D \fR\fB\fItablespace\fR\fR
70 \fB\-\-tablespace=\fR\fB\fItablespace\fR\fR
72 Specifies the default tablespace for the database\&. (This name is processed as a double\-quoted identifier\&.)
79 Echo the commands that
81 generates and sends to the server\&.
84 \fB\-E \fR\fB\fIencoding\fR\fR
86 \fB\-\-encoding=\fR\fB\fIencoding\fR\fR
88 Specifies the character encoding scheme to be used in this database\&. The character sets supported by the
90 server are described in
94 \fB\-l \fR\fB\fIlocale\fR\fR
96 \fB\-\-locale=\fR\fB\fIlocale\fR\fR
98 Specifies the locale to be used in this database\&. This is equivalent to specifying
99 \fB\-\-lc\-collate\fR,
100 \fB\-\-lc\-ctype\fR, and
101 \fB\-\-icu\-locale\fR
102 to the same value\&. Some locales are only valid for ICU and must be set with
103 \fB\-\-icu\-locale\fR\&.
106 \fB\-\-lc\-collate=\fR\fB\fIlocale\fR\fR
108 Specifies the LC_COLLATE setting to be used in this database\&.
111 \fB\-\-lc\-ctype=\fR\fB\fIlocale\fR\fR
113 Specifies the LC_CTYPE setting to be used in this database\&.
116 \fB\-\-builtin\-locale=\fR\fB\fIlocale\fR\fR
118 Specifies the locale name when the builtin provider is used\&. Locale support is described in
122 \fB\-\-icu\-locale=\fR\fB\fIlocale\fR\fR
124 Specifies the ICU locale ID to be used in this database, if the ICU locale provider is selected\&.
127 \fB\-\-icu\-rules=\fR\fB\fIrules\fR\fR
129 Specifies additional collation rules to customize the behavior of the default collation of this database\&. This is supported for ICU only\&.
132 \fB\-\-locale\-provider={\fR\fBbuiltin\fR\fB|\fR\fBlibc\fR\fB|\fR\fBicu\fR\fB}\fR
134 Specifies the locale provider for the database\*(Aqs default collation\&.
137 \fB\-O \fR\fB\fIowner\fR\fR
139 \fB\-\-owner=\fR\fB\fIowner\fR\fR
141 Specifies the database user who will own the new database\&. (This name is processed as a double\-quoted identifier\&.)
144 \fB\-S \fR\fB\fIstrategy\fR\fR
146 \fB\-\-strategy=\fR\fB\fIstrategy\fR\fR
148 Specifies the database creation strategy\&. See
149 CREATE DATABASE STRATEGY
153 \fB\-T \fR\fB\fItemplate\fR\fR
155 \fB\-\-template=\fR\fB\fItemplate\fR\fR
157 Specifies the template database from which to build this database\&. (This name is processed as a double\-quoted identifier\&.)
175 command line arguments, and exit\&.
184 correspond to options of the underlying SQL command
185 \fBCREATE DATABASE\fR; see there for more information about them\&.
188 also accepts the following command\-line arguments for connection parameters:
190 \fB\-h \fR\fB\fIhost\fR\fR
192 \fB\-\-host=\fR\fB\fIhost\fR\fR
194 Specifies the host name of the machine on which the server is running\&. If the value begins with a slash, it is used as the directory for the Unix domain socket\&.
197 \fB\-p \fR\fB\fIport\fR\fR
199 \fB\-\-port=\fR\fB\fIport\fR\fR
201 Specifies the TCP port or the local Unix domain socket file extension on which the server is listening for connections\&.
204 \fB\-U \fR\fB\fIusername\fR\fR
206 \fB\-\-username=\fR\fB\fIusername\fR\fR
208 User name to connect as\&.
213 \fB\-\-no\-password\fR
215 Never issue a password prompt\&. If the server requires password authentication and a password is not available by other means such as a
217 file, the connection attempt will fail\&. This option can be useful in batch jobs and scripts where no user is present to enter a password\&.
226 to prompt for a password before connecting to a database\&.
228 This option is never essential, since
230 will automatically prompt for a password if the server demands password authentication\&. However,
232 will waste a connection attempt finding out that the server wants a password\&. In some cases it is worth typing
234 to avoid the extra connection attempt\&.
237 \fB\-\-maintenance\-db=\fR\fB\fIdbname\fR\fR
239 Specifies the name of the database to connect to when creating the new database\&. If not specified, the
241 database will be used; if that does not exist (or if it is the name of the new database being created),
243 will be used\&. This can be a
244 connection string\&. If so, connection string parameters will override any conflicting command line options\&.
250 If set, the name of the database to create, unless overridden on the command line\&.
259 Default connection parameters\&.
261 also determines the name of the database to create, if it is not specified on the command line or by
267 Specifies whether to use color in diagnostic messages\&. Possible values are
274 This utility, like most other
276 utilities, also uses the environment variables supported by
282 In case of difficulty, see
283 CREATE DATABASE (\fBCREATE_DATABASE\fR(7))
286 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
288 front\-end library will apply\&.
291 To create the database
293 using the default database server:
299 $ \fBcreatedb demo\fR
305 To create the database
307 using the server on host
308 eden, port 5000, using the
310 template database, here is the command\-line command and the underlying SQL command:
316 $ \fBcreatedb \-p 5000 \-h eden \-T template0 \-e demo\fR
317 CREATE DATABASE demo TEMPLATE template0;
323 \fBdropdb\fR(1), CREATE DATABASE (\fBCREATE_DATABASE\fR(7))