| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/drop_schema.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="sql-dropschema"> |
| 7 |
<indexterm zone="sql-dropschema"> |
| 8 |
<primary>DROP SCHEMA</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle>DROP SCHEMA</refentrytitle> |
| 13 |
<manvolnum>7</manvolnum> |
| 14 |
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>DROP SCHEMA</refname> |
| 19 |
<refpurpose>remove a schema</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<synopsis> |
| 24 |
DROP SCHEMA [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ] |
| 25 |
</synopsis> |
| 26 |
</refsynopsisdiv> |
| 27 |
|
| 28 |
<refsect1> |
| 29 |
<title>Description</title> |
| 30 |
|
| 31 |
<para> |
| 32 |
<command>DROP SCHEMA</command> removes schemas from the database. |
| 33 |
</para> |
| 34 |
|
| 35 |
<para> |
| 36 |
A schema can only be dropped by its owner or a superuser. Note that |
| 37 |
the owner can drop the schema (and thereby all contained objects) |
| 38 |
even if they do not own some of the objects within the schema. |
| 39 |
</para> |
| 40 |
</refsect1> |
| 41 |
|
| 42 |
<refsect1> |
| 43 |
<title>Parameters</title> |
| 44 |
|
| 45 |
<variablelist> |
| 46 |
<varlistentry> |
| 47 |
<term><literal>IF EXISTS</literal></term> |
| 48 |
<listitem> |
| 49 |
<para> |
| 50 |
Do not throw an error if the schema does not exist. A notice is issued |
| 51 |
in this case. |
| 52 |
</para> |
| 53 |
</listitem> |
| 54 |
</varlistentry> |
| 55 |
|
| 56 |
<varlistentry> |
| 57 |
<term><replaceable class="parameter">name</replaceable></term> |
| 58 |
<listitem> |
| 59 |
<para> |
| 60 |
The name of a schema. |
| 61 |
</para> |
| 62 |
</listitem> |
| 63 |
</varlistentry> |
| 64 |
|
| 65 |
<varlistentry> |
| 66 |
<term><literal>CASCADE</literal></term> |
| 67 |
<listitem> |
| 68 |
<para> |
| 69 |
Automatically drop objects (tables, functions, etc.) that are |
| 70 |
contained in the schema, |
| 71 |
and in turn all objects that depend on those objects |
| 72 |
(see <xref linkend="ddl-depend"/>). |
| 73 |
</para> |
| 74 |
</listitem> |
| 75 |
</varlistentry> |
| 76 |
|
| 77 |
<varlistentry> |
| 78 |
<term><literal>RESTRICT</literal></term> |
| 79 |
<listitem> |
| 80 |
<para> |
| 81 |
Refuse to drop the schema if it contains any objects. This is |
| 82 |
the default. |
| 83 |
</para> |
| 84 |
</listitem> |
| 85 |
</varlistentry> |
| 86 |
</variablelist> |
| 87 |
</refsect1> |
| 88 |
|
| 89 |
<refsect1> |
| 90 |
<title>Notes</title> |
| 91 |
|
| 92 |
<para> |
| 93 |
Using the <literal>CASCADE</literal> option might make the command |
| 94 |
remove objects in other schemas besides the one(s) named. |
| 95 |
</para> |
| 96 |
</refsect1> |
| 97 |
|
| 98 |
<refsect1> |
| 99 |
<title>Examples</title> |
| 100 |
|
| 101 |
<para> |
| 102 |
To remove schema <literal>mystuff</literal> from the database, |
| 103 |
along with everything it contains: |
| 104 |
|
| 105 |
<programlisting> |
| 106 |
DROP SCHEMA mystuff CASCADE; |
| 107 |
</programlisting></para> |
| 108 |
</refsect1> |
| 109 |
|
| 110 |
<refsect1> |
| 111 |
<title>Compatibility</title> |
| 112 |
|
| 113 |
<para> |
| 114 |
<command>DROP SCHEMA</command> is fully conforming with the SQL |
| 115 |
standard, except that the standard only allows one schema to be |
| 116 |
dropped per command, and apart from the |
| 117 |
<literal>IF EXISTS</literal> option, which is a <productname>PostgreSQL</productname> |
| 118 |
extension. |
| 119 |
</para> |
| 120 |
</refsect1> |
| 121 |
|
| 122 |
<refsect1> |
| 123 |
<title>See Also</title> |
| 124 |
|
| 125 |
<simplelist type="inline"> |
| 126 |
<member><xref linkend="sql-alterschema"/></member> |
| 127 |
<member><xref linkend="sql-createschema"/></member> |
| 128 |
</simplelist> |
| 129 |
</refsect1> |
| 130 |
|
| 131 |
</refentry> |