2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.11 2000/11/11 23:01:38 petere Exp $
6 <refentry id="APP-CREATEDB" xreflabel="createdb">
8 <date>2000-11-11</date>
12 <refentrytitle id="APP-CREATEDB-TITLE"><application>createdb</application></refentrytitle>
13 <manvolnum>1</manvolnum>
14 <refmiscinfo>Application</refmiscinfo>
18 <refname>createdb</refname>
19 <refpurpose>Create a new <productname>Postgres</productname> database</refpurpose>
24 <command>createdb</command>
25 <arg rep="repeat"><replaceable>options</replaceable></arg>
26 <arg choice="plain"><replaceable>dbname</replaceable></arg>
27 <arg><replaceable>description</replaceable></arg>
30 <refsect2 id="R2-APP-CREATEDB-1">
38 <term>-h, --host <replaceable class="parameter">host</replaceable></term>
41 Specifies the hostname of the machine on which the
42 <application>postmaster</application>
49 <term>-p, --port <replaceable class="parameter">port</replaceable></term>
52 Specifies the Internet TCP/IP port or local Unix domain socket file
53 extension on which the <application>postmaster</application>
54 is listening for connections.
60 <term>-U, --username <replaceable class="parameter">username</replaceable></term>
63 Username to connect as.
69 <term>-W, --password</term>
72 Force password prompt.
78 <term>-e, --echo</term>
81 Echo the queries that <application>createdb</application> generates
82 and sends to the backend.
88 <term>-q, --quiet</term>
91 Do not display a response.
97 <term>-D, --location <replaceable class="parameter">datadir</replaceable></term>
100 Specifies the alternative database location. See also <xref
101 linkend="app-initlocation" endterm="app-initlocation-title">.
107 <term>-E, --encoding <replaceable class="parameter">encoding</replaceable></term>
110 Specifies the character encoding scheme to be used with this database.
116 <term><replaceable class="parameter">dbname</replaceable></term>
119 Specifies the name of the database to be created. The name must be
120 unique among all <productname>Postgres</productname> databases in this installation.
121 The default is to create a database with the same name as the
128 <term><replaceable class="parameter">description</replaceable></term>
131 This optionally specifies a comment to be associated with the newly created
139 The options <literal>-h</literal>, <literal>-p</literal>, <literal>-U</literal>,
140 <literal>-W</literal>, and <literal>-e</literal> are passed on literally to
141 <xref linkend="APP-PSQL" endterm="APP-PSQL-title">.
145 <refsect2 id="R2-APP-CREATEDB-2">
152 <term><computeroutput>CREATE DATABASE</computeroutput></term>
154 <para>The database was successfully created.</para>
159 <term><computeroutput>createdb: Database creation failed.</computeroutput></term>
161 <para>(Says it all.)</para>
166 <term><computeroutput>createdb: Comment creation failed. (Database was created.)</computeroutput></term>
169 The comment/description for the database could not be created.
170 the database itself will have been created already. You can use the
171 <acronym>SQL</acronym> command <command>COMMENT ON DATABASE</command> to
172 create the comment later on.
178 If there is an error condition, the backend error message will be displayed.
179 See <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title">
180 and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for possibilities.
185 <refsect1 id="R1-APP-CREATEDB-1">
190 <application>createdb</application> creates a new <productname>Postgres</productname>
191 database. The user who executes this command becomes the database owner.
195 <application>createdb</application> is a shell script wrapper around the
196 <acronym>SQL</acronym> command
197 <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title"> via
198 the <productname>Postgres</productname> interactive terminal
199 <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. Thus, there is nothing
200 special about creating databases via this or other methods. This means
201 that the <application>psql</application> must be found by the script and that
202 a database server is running at the targeted host. Also, any default
203 settings and environment variables available to <application>psql</application>
204 and the <application>libpq</application> front-end library do apply.
208 <refsect1 id="R1-APP-CREATEDB-2">
213 To create the database <literal>demo</literal> using the default
216 <prompt>$ </prompt><userinput>createdb demo</userinput>
217 <computeroutput>CREATE DATABASE</computeroutput>
219 The response is the same as you would have gotten from running the
220 <command>CREATE DATABASE</command> <acronym>SQL</acronym> command.
226 To create the database <literal>demo</literal> using the
227 postmaster on host eden, port 5000, using the
228 <literal>LATIN1</literal> encoding scheme with a look at the
231 <prompt>$ </prompt><userinput>createdb -p 5000 -h eden -E LATIN1 -e demo</userinput>
232 <computeroutput>CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'</computeroutput>
233 <computeroutput>CREATE DATABASE</computeroutput>
240 <!-- Keep this comment at the end of the file
245 sgml-minimize-attributes:nil
246 sgml-always-quote-attributes:t
249 sgml-parent-document:nil
250 sgml-default-dtd-file:"../reference.ced"
251 sgml-exposed-tags:nil
252 sgml-local-catalogs:"/usr/lib/sgml/catalog"
253 sgml-local-ecat-files:nil