Updated on 2024-06-03 GMT+08:00

DROP OWNED

Function

Deletes permissions on database objects owned by a database role.

Precautions

  • This interface will revoke the role's permissions on all objects in the current database and shared objects (databases and tablespaces).
  • DROP OWNED is often used to prepare for removing one or more roles. Because DROP OWNED affects only the objects in the current database, you need to run this statement in each database that contains the objects owned by the role to be removed.
  • Using the CASCADE option may cause this statement to recursively remove objects owned by other users.
  • The databases and tablespaces owned by the role will not be removed.
  • Private database links owned by a role can be deleted only after the CASCADE option is added.

Syntax

DROP OWNED BY name [, ...] [ CASCADE | RESTRICT ];

Parameter Description

  • name

    Specifies the role name.

  • CASCADE | RESTRICT
    • CASCADE: automatically deletes the objects that depend on the objects to be deleted.
    • RESTRICT: refuses to delete the object if any objects depend on it. This is the default action.

Examples

1
2
3
4
5
6
7
8
-- Create user jim.
gaussdb=# CREATE USER jim PASSWORD '********';

-- Revoke user jim's permissions on all objects in the current database and on shared objects (databases and tablespaces).
gaussdb=# DROP OWNED BY jim;

-- Delete user jim.
gaussdb=# DROP USER jim;

Helpful Links

REASSIGN OWNED and DROP ROLE