REASSIGN OWNED transfers ownership of all database objects owned by one or more source roles to a target role.
Synopsis
REASSIGN OWNED BY { old_role | CURRENT_USER | SESSION_USER } [, ...]
TO { new_role | CURRENT_USER | SESSION_USER }Parameters
| Parameter | Description |
|---|---|
old_role | The source role. All objects within the current database, and all shared objects (databases and tablespaces), owned by this role are reassigned to new_role. |
new_role | The target role that becomes the new owner of the affected objects. |
Usage notes
REASSIGN OWNEDonly affects objects in the current database. Because it does not affect objects within other databases, it is usually necessary to run it in each database that contains objects owned by the role you intend to remove.Membership in both the source role(s) and the target role is required to run this command.
DROP OWNEDis an alternative that simply drops all the database objects owned by one or more roles.REASSIGN OWNEDdoes not affect privileges granted toold_roleon objects it does not own, nor does it affect default privileges configured withALTER DEFAULT PRIVILEGES. RunDROP OWNEDto revoke those privileges.
See also
DROP OWNEDDROP ROLEALTER DEFAULT PRIVILEGES