REASSIGN_OWNED(7pg15)
π NAME π
This is the REASSIGN OWNED page, manual section 7, from the PostgreSQL 15.19 Documentation β yes bestie, it's giving role-cleanup era β¨
REASSIGN_OWNED β change the ownership of database objects owned by a database role π
β¨ SYNOPSIS β¨
REASSIGN OWNED BY { old_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...]
TO { new_role | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
πΈ DESCRIPTION πΈ
REASSIGN OWNED tells the system to change the ownership of database objects owned by any of the old_roles over to new_role. Literally handing over the keys, no cap πβ¨
π¦ PARAMETERS π¦
old_roleβ the 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 tonew_role. Sheβs packing up her stuff and moving out π§³new_roleβ the name of the role that will be made the new owner of the affected objects. New main character energy π
π 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. So yes, bestie, you may need to run it in every relevant database β no skipping π
REASSIGN OWNED requires membership on both the source role(s) and the target role. Membership check is mandatory, periodt π«Ά
The DROP OWNED command is an alternative that simply drops all the database objects owned by one or more roles. Different vibe, same cleanup family π
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. Important caveat, fr fr π
See Section 22.4 for more discussion. Go read the lore if you want the full tea πβ¨
π COMPATIBILITY π
The REASSIGN OWNED command is a PostgreSQL extension. Iconic, proprietary to our fave, iykyk π
β SEE ALSO β
DROP OWNED(DROP_OWNED(7))DROP ROLE(DROP_ROLE(7))ALTER DATABASE(ALTER_DATABASE(7))
mwah π this was PostgreSQL 15.19, dated 2026 β catch you in the docs, bestie π«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms