blob: 0fde37699ee0a5efe126e71594b45b43f74365f1 [file] [log] [blame]
---
title: DROP OWNED
---
<!--
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 database objects owned by a database role.
## <a id="topic1__section2"></a>Synopsis
``` pre
DROP OWNED BY <name> [, ...] [CASCADE | RESTRICT]
```
## <a id="topic1__section3"></a>Description
`DROP OWNED` drops all the objects in the current database that are owned by one of the specified roles. Any privileges granted to the given roles on objects in the current database will also be revoked.
## <a id="topic1__section4"></a>Parameters
<dt>\<name\> </dt>
<dd>The name of a role whose objects will be dropped, and whose privileges will be revoked.</dd>
<dt>CASCADE </dt>
<dd>Automatically drop objects that depend on the affected objects.</dd>
<dt>RESTRICT </dt>
<dd>Refuse to drop the objects owned by a role if any other database objects depend on one of the affected objects. This is the default.</dd>
## <a id="topic1__section5"></a>Notes
`DROP OWNED` is often used to prepare for the removal of one or more roles. Because `DROP OWNED` only affects the objects in the current database, it is usually necessary to execute this command in each database that contains objects owned by a role that is to be removed.
Using the `CASCADE` option may make the command recurse to objects owned by other users.
The `REASSIGN OWNED` command is an alternative that reassigns the ownership of all the database objects owned by one or more roles.
## <a id="topic1__section6"></a>Examples
Remove any database objects owned by the role named `sally`:
``` pre
DROP OWNED BY sally;
```
## <a id="topic1__section7"></a>Compatibility
The `DROP OWNED` statement is a HAWQ extension.
## <a id="topic1__section8"></a>See Also
[REASSIGN OWNED](REASSIGN-OWNED.html), [DROP ROLE](DROP-ROLE.html)