blob: 993bdddfb7b5d9a16fe8c138e0c30782edd5b630 [file]
---
title: DROP SCHEMA
---
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Removes a schema.
## <a id="topic1__section2"></a>Synopsis
``` pre
DROP SCHEMA [IF EXISTS] <name> [, ...] [CASCADE | RESTRICT]
```
## <a id="topic1__section3"></a>Description
`DROP SCHEMA` removes schemas from the database. A schema can only be dropped by its owner or a superuser. Note that the owner can drop the schema (and thereby all contained objects) even if he does not own some of the objects within the schema.
## <a id="topic1__section4"></a>Parameters
<dt>IF EXISTS </dt>
<dd>Do not throw an error if the schema does not exist. A notice is issued in this case.</dd>
<dt>\<name\> </dt>
<dd>The name of the schema to remove.</dd>
<dt>CASCADE </dt>
<dd>Automatically drops any objects contained in the schema (tables, functions, etc.).</dd>
<dt>RESTRICT </dt>
<dd>Refuse to drop the schema if it contains any objects. This is the default.</dd>
## <a id="topic1__section5"></a>Examples
Remove the schema `mystuff` from the database, along with everything it contains:
``` pre
DROP SCHEMA mystuff CASCADE;
```
## <a id="topic1__section6"></a>Compatibility
`DROP SCHEMA` is fully conforming with the SQL standard, except that the standard only allows one schema to be dropped per command. Also, the `IF EXISTS` option is a HAWQ extension.
## <a id="topic1__section7"></a>See Also
[CREATE SCHEMA](CREATE-SCHEMA.html)