1999-07-22 17:09:15 +02:00
|
|
|
<!--
|
|
|
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_database.sgml,v 1.9 1999/07/22 15:09:07 thomas Exp $
|
|
|
|
Postgres documentation
|
|
|
|
-->
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<refentry id="SQL-CREATEDATABASE">
|
|
|
|
<refmeta>
|
1999-07-22 17:09:15 +02:00
|
|
|
<refentrytitle id="sql-createdatabase-title">
|
1998-05-13 07:34:00 +02:00
|
|
|
CREATE DATABASE
|
1999-07-06 19:16:42 +02:00
|
|
|
</refentrytitle>
|
|
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
|
|
</refmeta>
|
|
|
|
<refnamediv>
|
|
|
|
<refname>
|
1998-05-13 07:34:00 +02:00
|
|
|
CREATE DATABASE
|
1999-07-06 19:16:42 +02:00
|
|
|
</refname>
|
|
|
|
<refpurpose>
|
1998-05-13 07:34:00 +02:00
|
|
|
Creates a new database
|
1999-07-06 19:16:42 +02:00
|
|
|
</refpurpose>
|
1998-12-29 03:24:47 +01:00
|
|
|
</refnamediv>
|
1999-07-06 19:16:42 +02:00
|
|
|
<refsynopsisdiv>
|
|
|
|
<refsynopsisdivinfo>
|
1999-07-22 17:09:15 +02:00
|
|
|
<date>1999-07-20</date>
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsynopsisdivinfo>
|
|
|
|
<synopsis>
|
|
|
|
CREATE DATABASE <replaceable class="PARAMETER">name</replaceable> [ WITH LOCATION = '<replaceable class="parameter">dbpath</replaceable>' ]
|
|
|
|
</synopsis>
|
|
|
|
|
|
|
|
<refsect2 id="R2-SQL-CREATEDATABASE-1">
|
|
|
|
<refsect2info>
|
|
|
|
<date>1998-04-15</date>
|
|
|
|
</refsect2info>
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
Inputs
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
<para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">name</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The name of a database to create.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">dbpath</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
1999-07-22 17:09:15 +02:00
|
|
|
An alternate location for the new database. See below for caveats.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
1998-12-29 03:24:47 +01:00
|
|
|
</para>
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsect2>
|
|
|
|
|
|
|
|
<refsect2 id="R2-SQL-CREATEDATABASE-2">
|
|
|
|
<refsect2info>
|
|
|
|
<date>1998-04-15</date>
|
|
|
|
</refsect2info>
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
Outputs
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
<para>
|
1998-10-30 20:34:40 +01:00
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><computeroutput>
|
|
|
|
CREATEDB
|
|
|
|
</computeroutput></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Message returned if the command completes successfully.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><computeroutput>
|
|
|
|
WARN: createdb: database "<replaceable class="parameter">name</replaceable>" already exists.
|
|
|
|
</computeroutput></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
This occurs if <replaceable class="parameter">database</replaceable> specified already exists.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><computeroutput>
|
|
|
|
ERROR: Unable to create database directory <replaceable class="parameter">directory</replaceable>
|
|
|
|
</computeroutput></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
1998-12-29 03:24:47 +01:00
|
|
|
There was a problem with creating the required directory; this operation will
|
|
|
|
need permissions for the <literal>postgres</literal> user on the specified location.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
1999-07-06 19:16:42 +02:00
|
|
|
</variablelist>
|
1998-12-29 03:24:47 +01:00
|
|
|
</para>
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsect2>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1 id="R1-SQL-CREATEDATABASE-1">
|
|
|
|
<refsect1info>
|
|
|
|
<date>1998-04-15</date>
|
|
|
|
</refsect1info>
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
Description
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
<para>
|
1998-05-29 15:16:36 +02:00
|
|
|
<command>CREATE DATABASE</command> creates a new Postgres database.
|
1998-05-13 07:34:00 +02:00
|
|
|
The creator becomes the administrator of the new database.
|
1999-07-06 19:16:42 +02:00
|
|
|
</para>
|
|
|
|
|
1999-07-22 17:09:15 +02:00
|
|
|
<para>
|
|
|
|
An alternate location can be specified as either an
|
|
|
|
environment variable known to the backend server
|
|
|
|
(e.g. '<envar>PGDATA2</envar>') or, if the server is built to
|
|
|
|
allow it, as an absolute path name
|
|
|
|
(e.g. '<filename>/usr/local/pgsql/data</filename>').
|
|
|
|
In either case, the location must be pre-configured
|
|
|
|
by <command>initlocation</command>.
|
|
|
|
</para>
|
|
|
|
|
1999-07-06 19:16:42 +02:00
|
|
|
<refsect2 id="R2-SQL-CREATEDATABASE-3">
|
|
|
|
<refsect2info>
|
|
|
|
<date>1998-04-15</date>
|
|
|
|
</refsect2info>
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
Notes
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
<para>
|
1998-09-16 16:43:12 +02:00
|
|
|
<command>CREATE DATABASE</command> is a <productname>Postgres</productname>
|
1999-07-06 19:16:42 +02:00
|
|
|
language extension.
|
|
|
|
</para>
|
1998-05-13 07:34:00 +02:00
|
|
|
<para>
|
1998-09-16 16:43:12 +02:00
|
|
|
Use <command>DROP DATABASE</command> to remove a database.
|
1998-05-13 07:34:00 +02:00
|
|
|
</para>
|
1999-07-22 17:09:15 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
There are security and data integrity issues
|
|
|
|
involved with using alternate database locations
|
|
|
|
specified with absolute path names, and by default
|
|
|
|
only an environment variable known to the backend may be
|
|
|
|
specified for an alternate location.
|
|
|
|
See the Administrator's Guide for more information.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
comment from Olly; response from Thomas...
|
|
|
|
<comment>
|
|
|
|
initlocation does not create a PG_VERSION file in the specified location.
|
|
|
|
How will Postgres handle the situation if it is upgraded to an
|
|
|
|
incompatible database version?
|
|
|
|
</comment>
|
|
|
|
Hmm. This isn't an issue since the upgrade would do
|
|
|
|
a dump/reload from the main database area also.
|
|
|
|
Not sure if the dump/reload would guarantee that
|
|
|
|
the alternate data area gets refreshed though...
|
|
|
|
-->
|
1999-07-06 19:16:42 +02:00
|
|
|
</refsect2>
|
1998-12-29 03:24:47 +01:00
|
|
|
</refsect1>
|
1999-07-06 19:16:42 +02:00
|
|
|
|
|
|
|
<refsect1 id="R1-SQL-CREATEDATABASE-2">
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
Usage
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
<para>
|
1998-05-13 07:34:00 +02:00
|
|
|
To create a new database:
|
1999-07-06 19:16:42 +02:00
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
<prompt>olly=></prompt> <userinput>create database lusiadas;</userinput>
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
1998-05-29 15:16:36 +02:00
|
|
|
To create a new database in an alternate area <filename>~/private_db</filename>:
|
1999-07-06 19:16:42 +02:00
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
<prompt>$</prompt> <userinput>mkdir private_db</userinput>
|
|
|
|
<prompt>$</prompt> <userinput>initlocation ~/private_db</userinput>
|
|
|
|
<computeroutput>Creating Postgres database system directory /home/olly/private_db/base</computeroutput>
|
1998-12-29 03:24:47 +01:00
|
|
|
|
|
|
|
<prompt>$</prompt> <userinput>psql olly</userinput>
|
|
|
|
<computeroutput>Welcome to the POSTGRESQL interactive sql monitor:
|
|
|
|
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
|
|
|
|
|
|
|
|
type \? for help on slash commands
|
|
|
|
type \q to quit
|
|
|
|
type \g or terminate with semicolon to execute query
|
|
|
|
You are currently connected to the database: template1
|
|
|
|
|
|
|
|
<prompt>olly=></prompt></computeroutput> <userinput>create database elsewhere with location = '/home/olly/private_db';</userinput>
|
|
|
|
<computeroutput>CREATEDB</computeroutput>
|
1999-07-06 19:16:42 +02:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 id="R1-SQL-CREATEDATABASE-4">
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
Compatibility
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
|
|
|
|
<refsect2 id="R2-SQL-CREATEDATABASE-4">
|
|
|
|
<refsect2info>
|
|
|
|
<date>1998-04-15</date>
|
|
|
|
</refsect2info>
|
|
|
|
<title>
|
1998-05-13 07:34:00 +02:00
|
|
|
SQL92
|
1999-07-06 19:16:42 +02:00
|
|
|
</title>
|
|
|
|
<para>
|
1998-09-16 16:43:12 +02:00
|
|
|
There is no <command>CREATE DATABASE</command> statement in SQL92.
|
1998-05-13 07:34:00 +02:00
|
|
|
The equivalent command in standard SQL is <command>CREATE SCHEMA</command>.
|
|
|
|
</para>
|
|
|
|
</refsect2>
|
|
|
|
</refsect1>
|
1999-07-06 19:16:42 +02:00
|
|
|
</refentry>
|
1998-05-13 07:34:00 +02:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
1999-07-06 19:16:42 +02:00
|
|
|
sgml-omittag:nil
|
1998-05-13 07:34:00 +02:00
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../reference.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
-->
|