1CREATEDB(1)             PostgreSQL Client Applications             CREATEDB(1)
2
3
4

NAME

6       createdb - create a new PostgreSQL database
7
8

SYNOPSIS

10       createdb [ option... ]  [ dbname ]  [ description ]
11

DESCRIPTION

13       createdb creates a new PostgreSQL database.
14
15       Normally, the database user who executes this command becomes the owner
16       of the new database.  However a different owner can  be  specified  via
17       the -O option, if the executing user has appropriate privileges.
18
19       createdb  is  a  wrapper  around  the SQL command CREATE DATABASE [cre‐
20       ate_database(7)].  There is no effective  difference  between  creating
21       databases  via  this  utility  and  via other methods for accessing the
22       server.
23

OPTIONS

25       createdb accepts the following command-line arguments:
26
27       dbname Specifies the name of the database to be created. The name  must
28              be  unique  among all PostgreSQL databases in this cluster.  The
29              default is to create a database with the same name as  the  cur‐
30              rent system user.
31
32       description
33              Specifies  a  comment  to  be  associated with the newly created
34              database.
35
36       -D tablespace
37
38       --tablespace tablespace
39              Specifies the default tablespace for the database.
40
41       -e
42
43       --echo Echo the commands that  createdb  generates  and  sends  to  the
44              server.
45
46       -l locale
47
48       --locale locale
49              Specifies the locale to be used in this database. This is equiv‐
50              alent to specifying both --lc-collate and --lc-ctype.
51
52       --lc-collate locale
53              Specifies the LC_COLLATE setting to be used in this database.
54
55       --lc-ctype locale
56              Specifies the LC_CTYPE setting to be used in this database.
57
58       -E encoding
59
60       --encoding encoding
61              Specifies the character encoding scheme to be used in this data‐
62              base.  The character sets supported by the PostgreSQL server are
63              described in in the documentation.
64
65       -O owner
66
67       --owner owner
68              Specifies the database user who will own the new database.
69
70       -T template
71
72       --template template
73              Specifies the template database from which to build  this  data‐
74              base.
75
76       The  options -D, -E, -l, -O, and -T correspond to options of the under‐
77       lying SQL command CREATE DATABASE [create_database(7)]; see  there  for
78       more information about them.
79
80       createdb  also accepts the following command-line arguments for connec‐
81       tion parameters:
82
83       -h host
84
85       --host host
86              Specifies the host name of the machine on which  the  server  is
87              running.  If  the  value  begins with a slash, it is used as the
88              directory for the Unix domain socket.
89
90       -p port
91
92       --port port
93              Specifies the TCP port or the  local  Unix  domain  socket  file
94              extension on which the server is listening for connections.
95
96       -U username
97
98       --username username
99              User name to connect as.
100
101       -w
102
103       --no-password
104              Never  issue  a password prompt. If the server requires password
105              authentication and a password is not available  by  other  means
106              such  as  a .pgpass file, the connection attempt will fail. This
107              option can be useful in batch jobs and scripts where no user  is
108              present to enter a password.
109
110       -W
111
112       --password
113              Force  createdb  to prompt for a password before connecting to a
114              database.
115
116              This option is never essential, since  createdb  will  automati‐
117              cally  prompt  for  a  password  if  the server demands password
118              authentication.   However,  createdb  will  waste  a  connection
119              attempt  finding  out that the server wants a password.  In some
120              cases it is worth  typing  -W  to  avoid  the  extra  connection
121              attempt.
122

ENVIRONMENT

124       PGDATABASE
125              If set, the name of the database to create, unless overridden on
126              the command line.
127
128       PGHOST
129
130       PGPORT
131
132       PGUSER Default connection parameters. PGUSER also determines  the  name
133              of the database to create, if it is not specified on the command
134              line or by PGDATABASE.
135
136       This utility, like most other PostgreSQL utilities, also uses the envi‐
137       ronment variables supported by libpq (see in the documentation).
138

DIAGNOSTICS

140       In  case  of  difficulty,  see CREATE DATABASE [create_database(7)] and
141       psql(1) for discussions of potential problems and error messages.   The
142       database server must be running at the targeted host. Also, any default
143       connection settings and environment variables used by the libpq  front-
144       end library will apply.
145

EXAMPLES

147       To create the database demo using the default database server:
148
149       $ createdb demo
150
151
152       To  create  the database demo using the server on host eden, port 5000,
153       using the LATIN1 encoding scheme with a look at the underlying command:
154
155       $ createdb -p 5000 -h eden -E LATIN1 -e demo
156       CREATE DATABASE demo ENCODING 'LATIN1';
157
158

SEE ALSO

160       dropdb(1), CREATE DATABASE [create_database(7)]
161
162
163
164Application                       2014-02-17                       CREATEDB(1)
Impressum