@@ -23,6 +23,8 @@ PostgreSQL documentation
2323<synopsis>
2424CREATE SCHEMA <replaceable class="parameter">schema_name</replaceable> [ AUTHORIZATION <replaceable class="parameter">user_name</replaceable> ] [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
2525CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">user_name</replaceable> [ <replaceable class="parameter">schema_element</replaceable> [ ... ] ]
26+ CREATE SCHEMA IF NOT EXISTS <replaceable class="parameter">schema_name</replaceable> [ AUTHORIZATION <replaceable class="parameter">user_name</replaceable> ]
27+ CREATE SCHEMA IF NOT EXISTS AUTHORIZATION <replaceable class="parameter">user_name</replaceable>
2628</synopsis>
2729 </refsynopsisdiv>
2830
@@ -98,6 +100,17 @@ CREATE SCHEMA AUTHORIZATION <replaceable class="parameter">user_name</replaceabl
98100 </para>
99101 </listitem>
100102 </varlistentry>
103+
104+ <varlistentry>
105+ <term><literal>IF NOT EXISTS</literal></term>
106+ <listitem>
107+ <para>
108+ Do nothing (except issuing a notice) if a schema with the same name
109+ already exists. <replaceable class="parameter">schema_element</>
110+ subcommands cannot be included when this option is used.
111+ </para>
112+ </listitem>
113+ </varlistentry>
101114 </variablelist>
102115 </refsect1>
103116
@@ -129,6 +142,15 @@ CREATE SCHEMA AUTHORIZATION joe;
129142</programlisting>
130143 </para>
131144
145+ <para>
146+ Create a schema named <literal>test</> that will be owned by user
147+ <literal>joe</>, unless there already is a schema named <literal>test</>.
148+ (It does not matter whether <literal>joe</> owns the pre-existing schema.)
149+ <programlisting>
150+ CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION joe;
151+ </programlisting>
152+ </para>
153+
132154 <para>
133155 Create a schema and create a table and view within it:
134156<programlisting>
@@ -177,6 +199,11 @@ CREATE VIEW hollywood.winners AS
177199 schema owner. This can happen only if the schema owner grants the
178200 <literal>CREATE</> privilege on his schema to someone else.
179201 </para>
202+
203+ <para>
204+ The <literal>IF NOT EXISTS</literal> option is a
205+ <productname>PostgreSQL</productname> extension.
206+ </para>
180207 </refsect1>
181208
182209 <refsect1>
0 commit comments