REASSIGN_OWNED(7pg15)

πŸ“¦ version 15.19, in opensuse-leap 16.0

πŸŽ€ 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 to new_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 ⭐


mwah πŸ’‹ this was PostgreSQL 15.19, dated 2026 β€” catch you in the docs, bestie πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from