File: app-createdb.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (185 lines) | stat: -rw-r--r-- 11,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>createdb</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="reference-client.html" title="PostgreSQL Client Applications">
<link rel="prev" href="app-clusterdb.html" title="clusterdb">
<link rel="next" href="app-createlang.html" title="createlang">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
<a name="app-createdb"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>createdb &#8212; create a new <span class="productname">PostgreSQL</span> database</p>
</div>
<a name="id791814"></a><div class="refsynopsisdiv">
<h2>Synopsis</h2>
<div class="cmdsynopsis"><p><code class="command">createdb</code> [<em class="replaceable"><code>option</code></em>...] [<em class="replaceable"><code>dbname</code></em>] [<em class="replaceable"><code>description</code></em>]</p></div>
</div>
<div class="refsect1" lang="en">
<a name="r1-app-createdb-1"></a><h2>   Description
  </h2>
<p>   <span class="application">createdb</span> creates a new <span class="productname">PostgreSQL</span>
   database.
  </p>
<p>   Normally, the database user who executes this command becomes the owner of
   the new database.
   However a different owner can be specified via the <code class="option">-O</code>
   option, if the executing user has appropriate privileges.
  </p>
<p>   <span class="application">createdb</span> is a wrapper around the
   <acronym class="acronym">SQL</acronym> command <a href="sql-createdatabase.html">CREATE DATABASE</a>.
   There is no effective difference between creating databases via
   this utility and via other methods for accessing the server.
  </p>
</div>
<div class="refsect1" lang="en">
<a name="id791922"></a><h2>Options</h2>
<p>   <span class="application">createdb</span> accepts the following command-line arguments:

    </p>
<div class="variablelist"><dl>
<dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt>
<dd><p>        Specifies the name of the database to be created.  The name must be
        unique among all <span class="productname">PostgreSQL</span> databases in this cluster.
        The default is to create a database with the same name as the
        current system user.
       </p></dd>
<dt><span class="term"><em class="replaceable"><code>description</code></em></span></dt>
<dd><p>        Specifies a comment to be associated with the newly created
        database.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-D <em class="replaceable"><code>tablespace</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--tablespace <em class="replaceable"><code>tablespace</code></em></code></span>
</dt>
<dd><p>        Specifies the default tablespace for the database.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-e</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--echo</code></span>
</dt>
<dd><p>        Echo the commands that <span class="application">createdb</span> generates
        and sends to the server.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-E <em class="replaceable"><code>encoding</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--encoding <em class="replaceable"><code>encoding</code></em></code></span>
</dt>
<dd><p>        Specifies the character encoding scheme to be used in this
        database. The character sets supported by the
        <span class="productname">PostgreSQL</span> server are described in
        <a href="multibyte.html#multibyte-charset-supported" title="21.2.1.Supported Character Sets">Section21.2.1, &#8220;Supported Character Sets&#8221;</a>.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-O <em class="replaceable"><code>owner</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--owner <em class="replaceable"><code>owner</code></em></code></span>
</dt>
<dd><p>        Specifies the database user who will own the new database.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-q</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--quiet</code></span>
</dt>
<dd><p>        Do not display a response.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-T <em class="replaceable"><code>template</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--template <em class="replaceable"><code>template</code></em></code></span>
</dt>
<dd><p>        Specifies the template database from which to build this database.
       </p></dd>
</dl></div>
<p>
   </p>
<p>    The options <code class="option">-D</code>, <code class="option">-E</code>,
    <code class="option">-O</code>, and
    <code class="option">-T</code> correspond to options of the underlying
    SQL command <a href="sql-createdatabase.html">CREATE DATABASE</a>; see there for more information
    about them.
   </p>
<p>    <span class="application">createdb</span> also accepts the following
    command-line arguments for connection parameters:

    </p>
<div class="variablelist"><dl>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-h <em class="replaceable"><code>host</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--host <em class="replaceable"><code>host</code></em></code></span>
</dt>
<dd><p>        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.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-p <em class="replaceable"><code>port</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--port <em class="replaceable"><code>port</code></em></code></span>
</dt>
<dd><p>        Specifies the TCP port or the local Unix domain socket file 
        extension on which the server is listening for connections.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-U <em class="replaceable"><code>username</code></em></code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--username <em class="replaceable"><code>username</code></em></code></span>
</dt>
<dd><p>        User name to connect as
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="option">-W</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="option">--password</code></span>
</dt>
<dd><p>        Force password prompt.
       </p></dd>
</dl></div>
<p>
   </p>
</div>
<div class="refsect1" lang="en">
<a name="id792254"></a><h2>Environment</h2>
<div class="variablelist"><dl>
<dt><span class="term"><code class="envar">PGDATABASE</code></span></dt>
<dd><p>      If set, the name of the database to create, unless overridden on
      the command line.
     </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="envar">PGHOST</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><code xmlns="" class="envar">PGPORT</code></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><code class="envar">PGUSER</code></span>
</dt>
<dd><p>      Default connection parameters.  <code class="envar">PGUSER</code> also
      determines the name of the database to create, if it is not
      specified on the command line or by <code class="envar">PGDATABASE</code>.
     </p></dd>
</dl></div>
</div>
<div class="refsect1" lang="en">
<a name="id792297"></a><h2>Diagnostics</h2>
<p>   In case of difficulty, see <a href="sql-createdatabase.html">CREATE DATABASE</a> and <a href="app-psql.html" title="psql"><span class="refentrytitle"><a name="app-psql-title"></a><span class="application">psql</span></span></a> 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 <span class="application">libpq</span> front-end
   library will apply.
  </p>
</div>
<div class="refsect1" lang="en">
<a name="id792332"></a><h2>Examples</h2>
<p>    To create the database <code class="literal">demo</code> using the default
    database server:
</p>
<pre class="screen"><code class="prompt">$ </code><strong class="userinput"><code>createdb demo</code></strong>
<code class="computeroutput">CREATE DATABASE</code></pre>
<p>
    The response is the same as you would have gotten from running the
    <code class="command">CREATE DATABASE</code> <acronym class="acronym">SQL</acronym> command.
   </p>
<p>    To create the database <code class="literal">demo</code> using the
    server on host <code class="literal">eden</code>, port 5000, using the
    <code class="literal">LATIN1</code> encoding scheme with a look at the
    underlying command:
</p>
<pre class="screen"><code class="prompt">$ </code><strong class="userinput"><code>createdb -p 5000 -h eden -E LATIN1 -e demo</code></strong>
<code class="computeroutput">CREATE DATABASE "demo" WITH ENCODING = 'LATIN1'</code>
<code class="computeroutput">CREATE DATABASE</code></pre>
<p>
   </p>
</div>
<div class="refsect1" lang="en">
<a name="id792432"></a><h2>See Also</h2>
<span class="simplelist"><a href="app-dropdb.html" title="dropdb"><span class="refentrytitle"><a name="app-dropdb-title"></a><span class="application">dropdb</span></span></a>, <a href="sql-createdatabase.html">CREATE DATABASE</a>, Environment Variables (<a href="libpq-envars.html" title="28.11.Environment Variables">Section28.11, &#8220;Environment Variables&#8221;</a>)</span>
</div>
</div></body>
</html>