From fb34e94d214d6767910df47aa7c605c452d11c57 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 3 Oct 2012 19:47:11 -0400 Subject: Support CREATE SCHEMA IF NOT EXISTS. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/src/sgml/ref/create_schema.sgml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'doc/src') 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 CREATE SCHEMA schema_name [ AUTHORIZATION user_name ] [ schema_element [ ... ] ] CREATE SCHEMA AUTHORIZATION user_name [ schema_element [ ... ] ] +CREATE SCHEMA IF NOT EXISTS schema_name [ AUTHORIZATION user_name ] +CREATE SCHEMA IF NOT EXISTS AUTHORIZATION user_name @@ -98,6 +100,17 @@ CREATE SCHEMA AUTHORIZATION user_name + + + IF NOT EXISTS + + + Do nothing (except issuing a notice) if a schema with the same name + already exists. schema_element + subcommands cannot be included when this option is used. + + + @@ -129,6 +142,15 @@ CREATE SCHEMA AUTHORIZATION joe; + + Create a schema named test that will be owned by user + joe, unless there already is a schema named test. + (It does not matter whether joe owns the pre-existing schema.) + +CREATE SCHEMA IF NOT EXISTS test AUTHORIZATION joe; + + + Create a schema and create a table and view within it: @@ -177,6 +199,11 @@ CREATE VIEW hollywood.winners AS schema owner. This can happen only if the schema owner grants the CREATE privilege on his schema to someone else. + + + The IF NOT EXISTS option is a + PostgreSQL extension. + -- cgit v1.2.3