2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/createdb.sgml,v 1.10 2000/03/27 17:14:42 thomas Exp $
6 <refentry id="APP-CREATEDB" xreflabel="createdb">
8 <refentrytitle id="APP-CREATEDB-TITLE">
9 <application>createdb</application>
11 <refmiscinfo>Application</refmiscinfo>
15 <application>createdb</application>
18 Create a new <productname>Postgres</productname> database
23 <date>1999-11-07</date>
26 createdb [ <replaceable class="parameter">options</replaceable> ] <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">description</replaceable> ]
29 <refsect2 id="R2-APP-CREATEDB-1">
31 <date>1999-11-07</date>
40 <term>-h, --host <replaceable class="parameter">host</replaceable></term>
43 Specifies the hostname of the machine on which the
44 <application>postmaster</application>
51 <term>-p, --port <replaceable class="parameter">port</replaceable></term>
54 Specifies the Internet TCP/IP port or local Unix domain socket file
55 extension on which the <application>postmaster</application>
56 is listening for connections.
62 <term>-U, --username <replaceable class="parameter">username</replaceable></term>
65 Username to connect as.
71 <term>-W, --password</term>
74 Force password prompt.
80 <term>-e, --echo</term>
83 Echo the queries that <application>createdb</application> generates
84 and sends to the backend.
90 <term>-q, --quiet</term>
93 Do not display a response.
99 <term>-D, --location <replaceable class="parameter">datadir</replaceable></term>
102 Specifies the alternate database location for this database installation.
103 This is the location of the installation system tables, not the location
104 of this specific database, which may be different.
110 <term>-E, --encoding <replaceable class="parameter">encoding</replaceable></term>
113 Specifies the character encoding scheme to be used with this database.
119 <term><replaceable class="parameter">dbname</replaceable></term>
122 Specifies the name of the database to be created. The name must be
123 unique among all <productname>Postgres</productname> databases in this installation.
124 The default is to create a database with the same name as the
131 <term><replaceable class="parameter">description</replaceable></term>
134 This optionally specifies a comment to be associated with the newly created
142 The options <literal>-h</literal>, <literal>-p</literal>, <literal>-U</literal>,
143 <literal>-W</literal>, and <literal>-e</literal> are passed on literally to
144 <xref linkend="APP-PSQL" endterm="APP-PSQL-title">.
148 <refsect2 id="R2-APP-CREATEDB-2">
150 <date>1999-11-07</date>
158 <term><computeroutput>CREATE DATABASE</computeroutput></term>
160 <para>The database was successfully created.</para>
165 <term><computeroutput>createdb: Database creation failed.</computeroutput></term>
167 <para>(Says it all.)</para>
172 <term><computeroutput>createdb: Comment creation failed. (Database was created.)</computeroutput></term>
175 The comment/description for the database could not be created.
176 the database itself will have been created already. You can use the
177 <acronym>SQL</acronym> command <command>COMMENT ON DATABASE</command> to
178 create the comment later on.
184 If there is an error condition, the backend error message will be displayed.
185 See <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title">
186 and <xref linkend="APP-PSQL" endterm="APP-PSQL-title"> for possibilities.
191 <refsect1 id="R1-APP-CREATEDB-1">
193 <date>1999-11-07</date>
199 <application>createdb</application> creates a new <productname>Postgres</productname>
200 database. The user who executes this command becomes the database owner.
204 <application>createdb</application> is a shell script wrapper around the
205 <acronym>SQL</acronym> command
206 <xref linkend="SQL-CREATEDATABASE" endterm="SQL-CREATEDATABASE-title"> via
207 the <productname>Postgres</productname> interactive terminal
208 <xref linkend="APP-PSQL" endterm="APP-PSQL-title">. Thus, there is nothing
209 special about creating databases via this or other methods. This means
210 that the <application>psql</application> must be found by the script and that
211 a database server is running at the targeted host. Also, any default
212 settings and environment variables available to <application>psql</application>
213 and the <application>libpq</application> front-end library do apply.
217 <refsect1 id="R1-APP-CREATEDB-2">
219 <date>1999-11-07</date>
225 To create the database <literal>demo</literal>
226 using the default database server:
229 $ <userinput>createdb demo</userinput>
233 The response is the same as you would have gotten from running the
234 <command>CREATE DATABASE</command> <acronym>SQL</acronym> command.
238 To create the database <literal>demo</literal>
239 using the postmaster on host eden, port 5000, using the <literal>LATIN1</literal>
240 encoding scheme with a look at the underlying query:
243 $ <userinput>createdb -p 5000 -h eden -E LATIN1 -e demo</userinput>
244 CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'
251 <!-- Keep this comment at the end of the file
256 sgml-minimize-attributes:nil
257 sgml-always-quote-attributes:t
260 sgml-parent-document:nil
261 sgml-default-dtd-file:"../reference.ced"
262 sgml-exposed-tags:nil
263 sgml-local-catalogs:"/usr/lib/sgml/catalog"
264 sgml-local-ecat-files:nil