REASSIGN OWNED
change the ownership of 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-REASSIGN-OWNED
- file
- sql-reassign-owned.html
- lang
- en
- name
- REASSIGN OWNED
- purpose
- change the ownership of database objects owned by a database role
- purpose zh
- 更改一个数据库角色所拥有的数据库对象的所有权
- sections same as
- Unknown
- slug
- 18
- synopsis text
- REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] TO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
Syntax
REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]
TO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }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
REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]
TO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }Description
REASSIGN OWNED instructs the system to change
the ownership of database objects owned by any of the
old_roles to
new_role.
Parameters
old_roleThe name of a role. The ownership of all the objects within the current database, and of all shared objects (databases, tablespaces), owned by this role will be reassigned to
new_role.new_roleThe name of the role that will be made the new owner of the affected objects.
Notes
REASSIGN OWNED is often used to prepare for the
removal of one or more roles. Because REASSIGN
OWNED does not affect objects within other databases,
it is usually necessary to execute this command in each database
that contains objects owned by a role that is to be removed.
You must have every privilege that an individual ALTER ... OWNER
TO would require you to have. Unlike ALTER TABLE
... OWNER TO, ALTER TYPE ... OWNER TO, and
other relation and type ownership changes, this does not require the target
role to have CREATE privilege on the containing schema.
The DROP OWNED command is an alternative that
simply drops all the database objects owned by one or more roles.
The REASSIGN OWNED command does not affect any
privileges granted to
the old_roles on objects
that are not owned by them. Likewise, it does not affect default
privileges created with ALTER DEFAULT PRIVILEGES.
Use DROP OWNED to revoke such privileges.
See Section 21.4 for more discussion.
Compatibility
The REASSIGN OWNED command is a
PostgreSQL extension.
See Also
DROP OWNED, DROP ROLE, ALTER DATABASECompare versions
Complete source facts
documentation revision
{"inputs":[{"file":"sql-reassign-owned.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"c77348140ef75a6bf143e8497025ac3f0e8827e1810df53cd1c02d128c1e2a96","version":"18.7"},{"file":"sql-reassign-owned.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"d1e37c9ee7fb375c08cbe62940f0737cc68a272e38d8cc8b25d4d7cb51dc667e","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}synopsis html
REASSIGN OWNED BY { <em class="replaceable"><code>old_role</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]
TO { <em class="replaceable"><code>new_role</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:21d8d8480038e0cdb4cebd5567f1515f29b7f0bf0ca955f6b2870eb7e542d37d
Text language: en · wiki-repair-20261023:21d8d8480038e0cdb4cebd5567f1515f29b7f0bf0ca955f6b2870eb7e542d37d