1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.10 1999/12/04 04:53:15 momjian Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.11 1999/12/12 05:15:09 momjian Exp $
3
3
Postgres documentation
4
4
-->
5
5
@@ -20,15 +20,15 @@ Postgres documentation
20
20
</refnamediv>
21
21
<refsynopsisdiv>
22
22
<refsynopsisdivinfo>
23
- <date>1999-07-20 </date>
23
+ <date>1999-12-11 </date>
24
24
</refsynopsisdivinfo>
25
25
<synopsis>
26
26
CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>' ]
27
27
</synopsis>
28
28
29
29
<refsect2 id="R2-SQL-CREATEDATABASE-1">
30
30
<refsect2info>
31
- <date>1998-04-15 </date>
31
+ <date>1999-12-11 </date>
32
32
</refsect2info>
33
33
<title>
34
34
Inputs
@@ -48,7 +48,8 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATIO
48
48
<term><replaceable class="parameter">dbpath</replaceable></term>
49
49
<listitem>
50
50
<para>
51
- An alternate location for the new database. See below for caveats.
51
+ An alternate location where to store the new database in the filesystem.
52
+ See below for caveats.
52
53
</para>
53
54
</listitem>
54
55
</varlistentry>
@@ -58,7 +59,7 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATIO
58
59
59
60
<refsect2 id="R2-SQL-CREATEDATABASE-2">
60
61
<refsect2info>
61
- <date>1998-04-15 </date>
62
+ <date>1999-12-11 </date>
62
63
</refsect2info>
63
64
<title>
64
65
Outputs
@@ -67,66 +68,122 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATIO
67
68
68
69
<variablelist>
69
70
<varlistentry>
70
- <term><computeroutput>
71
- CREATE DATABASE
72
- </computeroutput></term>
71
+ <term><computeroutput>CREATE DATABASE</computeroutput></term>
73
72
<listitem>
74
73
<para>
75
74
Message returned if the command completes successfully.
76
75
</para>
77
76
</listitem>
78
77
</varlistentry>
78
+
79
+ <varlistentry>
80
+ <term><computeroutput>ERROR: user '<replaceable class="parameter">username</replaceable>' is not allowed to create/drop databases</computeroutput></term>
81
+ <listitem>
82
+ <para>
83
+ You must have the special CREATEDB privilege to create databases.
84
+ See <xref linkend="SQL-CREATEUSER" endterm="SQL-CREATEUSER-title">.
85
+ </para>
86
+ </listitem>
87
+ </varlistentry>
88
+
89
+
90
+ <varlistentry>
91
+ <term><computeroutput>ERROR: createdb: database "<replaceable class="parameter">name</replaceable>" already exists</computeroutput></term>
92
+ <listitem>
93
+ <para>
94
+ This occurs if a database with the <replaceable class="parameter">name</replaceable>
95
+ specified already exists.
96
+ </para>
97
+ </listitem>
98
+ </varlistentry>
99
+
79
100
<varlistentry>
80
- <term><computeroutput>
81
- WARN: createdb: database "<replaceable class="parameter">name</replaceable>" already exists.
82
- </computeroutput></term>
101
+ <term><computeroutput>ERROR: Single quotes are not allowed in database names.</computeroutput></term>
102
+ <term><computeroutput>ERROR: Single quotes are not allowed in database paths.</computeroutput></term>
83
103
<listitem>
84
104
<para>
85
- This occurs if <replaceable class="parameter">database</replaceable> specified already exists.
105
+ The database <replaceable class="parameter">name</replaceable> and
106
+ <replaceable class="parameter">dbpath</replaceable> cannot contain
107
+ single quotes. This is required so that the shell commands that
108
+ create the database directory can execute safely.
86
109
</para>
87
110
</listitem>
88
111
</varlistentry>
112
+
89
113
<varlistentry>
90
- <term><computeroutput>
91
- ERROR: Unable to create database directory <replaceable class="parameter">directory</replaceable>
92
- </computeroutput></term>
114
+ <term><computeroutput>ERROR: The path 'xxx' is invalid.</computeroutput></term>
93
115
<listitem>
94
116
<para>
95
- There was a problem with creating the required directory; this operation will
96
- need permissions for the <literal>postgres</literal> user on the specified location.
117
+ The expansion of the specified <replaceable class="parameter">dbpath</replaceable>
118
+ (see below how) failed. Check the path you entered or make sure that the
119
+ environment variable you are referencing does exist.
97
120
</para>
98
121
</listitem>
99
122
</varlistentry>
123
+
124
+ <varlistentry>
125
+ <term><computeroutput>ERROR: createdb: May not be called in a transaction block.</computeroutput></term>
126
+ <listitem>
127
+ <para>
128
+ If you have an explicit transaction block in progress you cannot call
129
+ <command>CREATE DATABASE</command>. You must finish the transaction first.
130
+ </para>
131
+ </listitem>
132
+ </varlistentry>
133
+
134
+ <varlistentry>
135
+ <term><computeroutput>ERROR: Unable to create database directory 'xxx'.</computeroutput></term>
136
+ <term><computeroutput>ERROR: Could not initialize database directory.</computeroutput></term>
137
+ <listitem>
138
+ <para>
139
+ These are most likely related to insufficient permissions on the data
140
+ directory, a full disk, or other file system problems. The user under
141
+ which the database server is running, must have access to the location.
142
+ </para>
143
+ </listitem>
144
+ </varlistentry>
145
+
100
146
</variablelist>
101
147
</para>
102
148
</refsect2>
103
149
</refsynopsisdiv>
104
150
105
151
<refsect1 id="R1-SQL-CREATEDATABASE-1">
106
152
<refsect1info>
107
- <date>1998-04-15 </date>
153
+ <date>1999-12-11 </date>
108
154
</refsect1info>
109
155
<title>
110
156
Description
111
157
</title>
112
158
<para>
113
- <command>CREATE DATABASE</command> creates a new Postgres database.
114
- The creator becomes the administrator of the new database.
159
+ <command>CREATE DATABASE</command> creates a new
160
+ <productname>PostgreSQL</productname> database.
161
+ The creator becomes the owner of the new database.
115
162
</para>
116
163
117
164
<para>
118
- An alternate location can be specified as either an
119
- environment variable known to the backend server
120
- (e.g. '<envar>PGDATA2</envar>') or, if the server is built to
121
- allow it, as an absolute path name
122
- (e.g. '<filename>/usr/local/pgsql/data</filename>').
123
- In either case, the location must be pre-configured
124
- by <command>initlocation</command>.
165
+ An alternate location can be specified in order to,
166
+ for example, store the database on a different disk.
167
+ The path must have been prepared with the <xref
168
+ linkend="APP-INITLOCATION" endterm="APP-INITLOCATION-title">
169
+ command.
170
+ </para>
171
+ <para>
172
+ If the path contains a slash, the leading part is interpreted
173
+ as an environment variable, which must be known to the
174
+ server process. This way the database administrator can
175
+ exercise control over at which locations databases can be created.
176
+ (A customary choice is, e.g., '<envar>PGDATA2</envar>'.)
177
+ If the server is compiled with <literal>ALLOW_ABSOLUTE_DBPATHS</literal>
178
+ (not so by default), absolute path names, as identified by
179
+ a leading slash
180
+ (e.g. '<filename>/usr/local/pgsql/data</filename>'),
181
+ are allowed as well.
125
182
</para>
126
183
127
184
<refsect2 id="R2-SQL-CREATEDATABASE-3">
128
185
<refsect2info>
129
- <date>1998-04-15 </date>
186
+ <date>1999-12-11 </date>
130
187
</refsect2info>
131
188
<title>
132
189
Notes
@@ -136,7 +193,11 @@ ERROR: Unable to create database directory <replaceable class="parameter">direc
136
193
language extension.
137
194
</para>
138
195
<para>
139
- Use <command>DROP DATABASE</command> to remove a database.
196
+ Use <xref linkend="SQL-DROPDATABASE" endterm="SQL-DROPDATABASE-title"> to remove a database.
197
+ </para>
198
+ <para>
199
+ The program <xref linkend="APP-CREATEDB" endterm="APP-CREATEDB-title"> is a
200
+ shell script wrapper around this command, provided for convenience.
140
201
</para>
141
202
142
203
<para>
@@ -183,16 +244,16 @@ comment from Olly; response from Thomas...
183
244
<prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
184
245
<computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
185
246
186
- <prompt>$</prompt> <userinput>psql olly</userinput>
187
- <computeroutput>Welcome to psql, the PostgreSQL interactive terminal.
247
+ <prompt>$</prompt> <userinput>psql olly</userinput>
248
+ <computeroutput>Welcome to psql, the PostgreSQL interactive terminal.
188
249
(Please type \copyright to see the distribution terms of PostgreSQL.)
189
250
190
251
Type \h for help with SQL commands,
191
252
\? for help on internal slash commands,
192
253
\q to quit,
193
254
\g or terminate with semicolon to execute query.
194
- <prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
195
- <computeroutput>CREATE DATABASE</computeroutput>
255
+ <prompt>olly=></prompt></computeroutput> <userinput>CREATE DATABASE elsewhere WITH LOCATION = '/home/olly/private_db';</userinput>
256
+ <computeroutput>CREATE DATABASE</computeroutput>
196
257
</programlisting>
197
258
</para>
198
259
</refsect1>
0 commit comments