aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/create_schema.sgml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/sgml/ref/create_schema.sgml')
-rw-r--r--doc/src/sgml/ref/create_schema.sgml244
1 files changed, 109 insertions, 135 deletions
diff --git a/doc/src/sgml/ref/create_schema.sgml b/doc/src/sgml/ref/create_schema.sgml
index 7fd2aa3880c..9f32a8f342e 100644
--- a/doc/src/sgml/ref/create_schema.sgml
+++ b/doc/src/sgml/ref/create_schema.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.4 2003/02/03 15:56:50 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_schema.sgml,v 1.5 2003/04/22 10:08:08 petere Exp $
PostgreSQL documentation
-->
@@ -8,25 +8,51 @@ PostgreSQL documentation
<refentrytitle id="sql-createschema-title">CREATE SCHEMA</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
+
<refnamediv>
- <refname>
- CREATE SCHEMA
- </refname>
- <refpurpose>
- define a new schema
- </refpurpose>
+ <refname>CREATE SCHEMA</refname>
+ <refpurpose>define a new schema</refpurpose>
</refnamediv>
+
<refsynopsisdiv>
- <synopsis>
+<synopsis>
CREATE SCHEMA <replaceable class="parameter">schemaname</replaceable> [ AUTHORIZATION <replaceable class="parameter">username</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable> [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
- </synopsis>
+</synopsis>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Description</title>
+
+ <para>
+ <command>CREATE SCHEMA</command> will enter a new schema
+ into the current database.
+ The schema name must be distinct from the name of any existing schema
+ in the current database.
+ </para>
+
+ <para>
+ A schema is essentially a namespace:
+ it contains named objects (tables, data types, functions, and operators)
+ whose names may duplicate those of other objects existing in other
+ schemas. Named objects are accessed either by <quote>qualifying</>
+ their names with the schema name as a prefix, or by setting a search
+ path that includes the desired schema(s). Unqualified objects are
+ created in the current schema (the one at the front of the search path,
+ which can be determined with the function <function>current_schema</function>).
+ </para>
+
+ <para>
+ Optionally, <command>CREATE SCHEMA</command> can include subcommands
+ to create objects within the new schema. The subcommands are treated
+ essentially the same as separate commands issued after creating the
+ schema, except that if the <literal>AUTHORIZATION</> clause is used,
+ all the created objects will be owned by that user.
+ </para>
+ </refsect1>
- <refsect2 id="R2-SQL-CREATESCHEMA-1">
- <title>
- Inputs
- </title>
- <para>
+ <refsect1>
+ <title>Parameters</title>
<variablelist>
<varlistentry>
@@ -63,164 +89,112 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">username</replaceable
</listitem>
</varlistentry>
</variablelist>
- </para>
- </refsect2>
-
- <refsect2 id="R2-SQL-CREATESCHEMA-2">
- <title>
- Outputs
- </title>
- <para>
+ </refsect1>
- <variablelist>
- <varlistentry>
- <term><computeroutput>
-CREATE SCHEMA
- </computeroutput></term>
- <listitem>
- <para>
- Message returned if the command is successful.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><computeroutput>
-ERROR: namespace "<replaceable class="parameter">schemaname</replaceable>" already exists
- </computeroutput></term>
- <listitem>
- <para>
- If the schema specified already exists.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </para>
- </refsect2>
- </refsynopsisdiv>
+ <refsect1>
+ <title>Diagnostics</title>
+
+ <variablelist>
+ <varlistentry>
+ <term><computeroutput>CREATE SCHEMA</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the schema was successfully created.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><computeroutput>ERROR: namespace "<replaceable class="parameter">schemaname</replaceable>" already exists</computeroutput></term>
+ <listitem>
+ <para>
+ Message returned if the schema specified already exists.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
- <refsect1 id="R1-SQL-CREATESCHEMA-1">
- <title>
- Description
- </title>
- <para>
- <command>CREATE SCHEMA</command> will enter a new schema
- into the current database.
- The schema name must be distinct from the name of any existing schema
- in the current database.
- </para>
+ <refsect1>
+ <title>Notes</title>
<para>
- A schema is essentially a namespace:
- it contains named objects (tables, data types, functions, and operators)
- whose names may duplicate those of other objects existing in other
- schemas. Named objects are accessed either by <quote>qualifying</>
- their names with the schema name as a prefix, or by setting a search
- path that includes the desired schema(s). Unqualified objects are
- created in the current schema (the one at the front of the search path;
- see <literal>CURRENT_SCHEMA()</>).
+ To create a schema, the invoking user must have <literal>CREATE</>
+ privilege for the current database. (Of course, superusers bypass
+ this check.)
</para>
<para>
- Optionally, <command>CREATE SCHEMA</command> can include subcommands
- to create objects within the new schema. The subcommands are treated
- essentially the same as separate commands issued after creating the
- schema, except that if the <literal>AUTHORIZATION</> clause is used,
- all the created objects will be owned by that user.
+ Use <command>DROP SCHEMA</command> to remove a schema.
</para>
-
- <refsect2 id="R2-SQL-CREATESCHEMA-3">
- <title>
- Notes
- </title>
-
- <para>
- To create a schema, the invoking user must have <literal>CREATE</>
- privilege for the current database. (Of course, superusers bypass
- this check.)
- </para>
-
- <para>
- Use <command>DROP SCHEMA</command> to remove a schema.
- </para>
- </refsect2>
</refsect1>
- <refsect1 id="R1-SQL-CREATESCHEMA-2">
- <title>
- Examples
- </title>
+ <refsect1>
+ <title>Examples</title>
+
<para>
Create a schema:
-
- <programlisting>
+<programlisting>
CREATE SCHEMA myschema;
- </programlisting>
+</programlisting>
</para>
<para>
- Create a schema for user <literal>joe</> --- the schema will also
- be named <literal>joe</>:
-
- <programlisting>
+ Create a schema for user <literal>joe</>; the schema will also be
+ named <literal>joe</>:
+<programlisting>
CREATE SCHEMA AUTHORIZATION joe;
- </programlisting>
+</programlisting>
</para>
<para>
Create a schema and create a table and view within it:
-
- <programlisting>
+<programlisting>
CREATE SCHEMA hollywood
CREATE TABLE films (title text, release date, awards text[])
CREATE VIEW winners AS
SELECT title, release FROM films WHERE awards IS NOT NULL;
- </programlisting>
+</programlisting>
Notice that the individual subcommands do not end with semicolons.
</para>
<para>
The following is an equivalent way of accomplishing the same result:
- <programlisting>
+<programlisting>
CREATE SCHEMA hollywood;
CREATE TABLE hollywood.films (title text, release date, awards text[]);
CREATE VIEW hollywood.winners AS
SELECT title, release FROM hollywood.films WHERE awards IS NOT NULL;
- </programlisting>
+</programlisting>
</para>
</refsect1>
- <refsect1 id="R1-SQL-CREATESCHEMA-3">
- <title>
- Compatibility
- </title>
-
- <refsect2 id="R2-SQL-CREATESCHEMA-4">
- <title>
- SQL92
- </title>
-
- <para>
- SQL92 allows a <literal>DEFAULT CHARACTER SET</> clause in
- <command>CREATE SCHEMA</command>, as well as more subcommand types
- than are presently accepted by <productname>PostgreSQL</productname>.
- </para>
-
- <para>
- SQL92 specifies that the subcommands in <command>CREATE SCHEMA</command>
- may appear in any order. The present
- <productname>PostgreSQL</productname> implementation does not handle all
- cases of forward references in subcommands; it may sometimes be necessary
- to reorder the subcommands to avoid forward references.
- </para>
-
- <para>
- In SQL92, the owner of a schema always owns all objects within it.
- <productname>PostgreSQL</productname> allows schemas to contain objects
- owned by users other than the schema owner. This can happen only if the
- schema owner grants <literal>CREATE</> rights on his schema to someone
- else.
- </para>
- </refsect2>
+ <refsect1>
+ <title>Compatibility</title>
+
+ <para>
+ The SQL standard allows a <literal>DEFAULT CHARACTER SET</> clause
+ in <command>CREATE SCHEMA</command>, as well as more subcommand
+ types than are presently accepted by
+ <productname>PostgreSQL</productname>.
+ </para>
+
+ <para>
+ The SQL standard specifies that the subcommands in <command>CREATE
+ SCHEMA</command> may appear in any order. The present
+ <productname>PostgreSQL</productname> implementation does not
+ handle all cases of forward references in subcommands; it may
+ sometimes be necessary to reorder the subcommands to avoid forward
+ references.
+ </para>
+
+ <para>
+ According to the SQL standard, the owner of a schema always owns
+ all objects within it. <productname>PostgreSQL</productname>
+ allows schemas to contain objects owned by users other than the
+ schema owner. This can happen only if the schema owner grants the
+ <literal>CREATE</> privilege on his schema to someone else.
+ </para>
</refsect1>
</refentry>