1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 >Creating a Database</TITLE
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
15 TITLE="Managing Databases"
16 HREF="managing-databases.html"><LINK
18 TITLE="Managing Databases"
19 HREF="managing-databases.html"><LINK
21 TITLE="Template Databases"
22 HREF="manage-ag-templatedbs.html"><LINK
25 HREF="stylesheet.css"><META
27 CONTENT="2003-12-22T03:48:47"></HEAD
33 SUMMARY="Header navigation table"
43 >PostgreSQL 7.4.1 Documentation</TH
51 HREF="managing-databases.html"
60 HREF="managing-databases.html"
67 >Chapter 18. Managing Databases</TD
73 HREF="managing-databases.html"
81 HREF="manage-ag-templatedbs.html"
95 NAME="MANAGE-AG-CREATEDB"
96 >18.2. Creating a Database</A
99 > In order to create a databases, the <SPAN
103 server must be up and running (see <A
104 HREF="postmaster-start.html"
109 > Databases are created with the SQL command <TT
119 >CREATE DATABASE <VAR
127 > follows the usual rules for
131 > identifiers. The current user automatically
132 becomes the owner of the new database. It is the privilege of the
133 owner of a database to remove it later on (which also removes all
134 the objects in it, even if they have a different owner).
137 > The creation of databases is a restricted operation. See <A
138 HREF="user-attributes.html"
140 > for how to grant permission.
143 > Since you need to be connected to the database server in order to
148 question remains how the <SPAN
154 > database at any given
155 site can be created. The first database is always created by the
159 > command when the data storage area is
161 HREF="creating-cluster.html"
172 create the first <SPAN
175 > database you can connect to
185 > is no accident: When a new
186 database is created, the template database is essentially cloned.
187 This means that any changes you make in <TT
191 propagated to all subsequently created databases. This implies that
192 you should not use the template database for real work, but when
193 used judiciously this feature can be convenient. More details
195 HREF="manage-ag-templatedbs.html"
200 > As an extra convenience, there is also a program that you can
201 execute from the shell to create new databases,
221 > does no magic. It connects to the <TT
225 database and issues the <TT
229 exactly as described above.
230 The reference page on <TT
233 > contains the invocation
234 details. Note that <TT
237 > without any arguments will create
238 a database with the current user name, which may or may not be what
249 HREF="client-authentication.html"
251 > contains information about
252 how to restrict who can connect to a given database.
257 > Sometimes you want to create a database for someone else. That
258 user should become the owner of the new database, so he can
259 configure and manage it himself. To achieve that, use one of the
262 CLASS="PROGRAMLISTING"
263 >CREATE DATABASE <VAR
271 from the SQL environment, or
273 CLASS="PROGRAMLISTING"
282 You must be a superuser to be allowed to create a database for
291 SUMMARY="Footer navigation table"
302 HREF="managing-databases.html"
320 HREF="manage-ag-templatedbs.html"
330 >Managing Databases</TD
336 HREF="managing-databases.html"
344 >Template Databases</TD