diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-10-03 19:47:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-10-03 19:47:11 -0400 |
commit | fb34e94d214d6767910df47aa7c605c452d11c57 (patch) | |
tree | 2e8a4161779f1a32c556b6e4acc5db4cb783db17 /doc/src | |
parent | 994c36e01d19dece2b0c76fb781e1d08a6e1c814 (diff) | |
download | postgresql-fb34e94d214d6767910df47aa7c605c452d11c57.tar.gz postgresql-fb34e94d214d6767910df47aa7c605c452d11c57.zip |
Support CREATE SCHEMA IF NOT EXISTS.
Per discussion, schema-element subcommands are not allowed together with
this option, since it's not very obvious what should happen to the element
objects.
FabrÃzio de Royes Mello
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/ref/create_schema.sgml | 27 |
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> |