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       -E encoding
47
48       --encoding encoding
49              Specifies the character encoding scheme to be used in this data‐
50              base. The character sets supported by the PostgreSQL server  are
51              described in in the documentation.
52
53       -O owner
54
55       --owner owner
56              Specifies the database user who will own the new database.
57
58       -q
59
60       --quiet
61              Do not display a response.
62
63       -T template
64
65       --template template
66              Specifies  the  template database from which to build this data‐
67              base.
68
69       The options -D, -E, -O, and -T correspond to options of the  underlying
70       SQL  command  CREATE  DATABASE [create_database(7)]; see there for more
71       information about them.
72
73       createdb also accepts the following command-line arguments for  connec‐
74       tion parameters:
75
76       -h host
77
78       --host host
79              Specifies  the  host  name of the machine on which the server is
80              running. If the value begins with a slash, it  is  used  as  the
81              directory for the Unix domain socket.
82
83       -p port
84
85       --port port
86              Specifies  the  TCP  port  or  the local Unix domain socket file
87              extension on which the server is listening for connections.
88
89       -U username
90
91       --username username
92              User name to connect as
93
94       -W
95
96       --password
97              Force password prompt.
98

ENVIRONMENT

100       PGDATABASE
101              If set, the name of the database to create, unless overridden on
102              the command line.
103
104       PGHOST
105
106       PGPORT
107
108       PGUSER Default  connection  parameters. PGUSER also determines the name
109              of the database to create, if it is not specified on the command
110              line or by PGDATABASE.
111
112       This utility, like most other PostgreSQL utilities, also uses the envi‐
113       ronment variables supported by libpq (see in the documentation).
114

DIAGNOSTICS

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

EXAMPLES

123       To create the database demo using the default database server:
124
125       $ createdb demo
126       CREATE DATABASE
127
128       The response is the same as you would have gotten from running the CRE‐
129       ATE DATABASE SQL command.
130
131       To  create  the database demo using the server on host eden, port 5000,
132       using the LATIN1 encoding scheme with a look at the underlying command:
133
134       $ createdb -p 5000 -h eden -E LATIN1 -e demo
135       CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'
136       CREATE DATABASE
137
138

SEE ALSO

140       dropdb(1), CREATE DATABASE [create_database(7)]
141
142
143
144Application                       2008-06-08                       CREATEDB(1)
Impressum