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.sgml27
1 files changed, 27 insertions, 0 deletions
diff --git a/doc/src/sgml/ref/create_schema.sgml b/doc/src/sgml/ref/create_schema.sgml
index 930d876814d..2602bb1d56f 100644
--- a/doc/src/sgml/ref/create_schema.sgml
+++ b/doc/src/sgml/ref/create_schema.sgml
@@ -23,6 +23,8 @@ PostgreSQL documentation
<synopsis>
CREATE SCHEMA <replaceable class="parameter">schema_name</replaceable> [ AUTHORIZATION <replaceable class="parameter">user_name</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">user_name</replaceable> [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
+CREATE SCHEMA IF NOT EXISTS <replaceable class="parameter">schema_name</replaceable> [ AUTHORIZATION <replaceable class="parameter">user_name</replaceable> ]
+CREATE SCHEMA IF NOT EXISTS AUTHORIZATION <replaceable class="parameter">user_name</replaceable>
</synopsis>
</refsynopsisdiv>
@@ -98,6 +100,17 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">user_name</replaceabl
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><literal>IF NOT EXISTS</literal></term>
+ <listitem>
+ <para>
+ Do nothing (except issuing a notice) if a schema with the same name
+ already exists. <replaceable class="parameter">schema_element</>
+ subcommands cannot be included when this option is used.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
@@ -130,6 +143,15 @@ CREATE SCHEMA AUTHORIZATION joe;
</para>
<para>
+ Create a schema named <literal>test</> that will be owned by user
+ <literal>joe</>, unless there already is a schema named <literal>test</>.
+ (It does not matter whether <literal>joe</> owns the pre-existing schema.)
+<programlisting>
+CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION joe;
+</programlisting>
+ </para>
+
+ <para>
Create a schema and create a table and view within it:
<programlisting>
CREATE SCHEMA hollywood
@@ -177,6 +199,11 @@ CREATE VIEW hollywood.winners AS
schema owner. This can happen only if the schema owner grants the
<literal>CREATE</> privilege on his schema to someone else.
</para>
+
+ <para>
+ The <literal>IF NOT EXISTS</literal> option is a
+ <productname>PostgreSQL</productname> extension.
+ </para>
</refsect1>
<refsect1>