DROP OWNED
remove database objects owned by a database role
English manual coverage begins with PostgreSQL 6.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- anchor
- SQL-DROP-OWNED
- file
- sql-drop-owned.html
- lang
- en
- name
- DROP OWNED
- purpose
- remove database objects owned by a database role
- purpose zh
- 移除一个数据库角色所拥有的数据库对象
- sections same as
- Unknown
- slug
- 18
- synopsis html
- DROP OWNED BY { <em class="replaceable"><code>name</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]
- synopsis text
- DROP OWNED BY { name | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]
Syntax
DROP OWNED BY { name | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]Syntax diagrams
Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.
Definition PG 18
DROP OWNED BY { name | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] [ CASCADE | RESTRICT ]Description
DROP OWNED drops all the objects within 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 or on shared objects (databases, tablespaces, configuration parameters) will also be revoked.
Parameters
nameThe name of a role whose objects will be dropped, and whose privileges will be revoked.
CASCADEAutomatically drop objects that depend on the affected objects, and in turn all objects that depend on those objects (see Section 5.15).
RESTRICTRefuse to drop the objects owned by a role if any other database objects depend on one of the affected objects. This is the default.
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 might 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. However, REASSIGN OWNED does not deal with privileges for other objects.
Databases and tablespaces owned by the role(s) will not be removed.
See Section 21.4 for more discussion.
Compatibility
The DROP OWNED command is a PostgreSQL extension.
See Also
REASSIGN OWNED, DROP ROLECompare versions
Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:7589969424f056982fafeabecd7d9d9e216cec7c0f350f6216f08db01f3a1230
Text language: en · wiki-repair-20261023:7589969424f056982fafeabecd7d9d9e216cec7c0f350f6216f08db01f3a1230