REASSIGN_OWNED(7pg13)

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

okay bestie, welcome to the REASSIGN_OWNED(7pg13) page β€” this is the REASSIGN OWNED command from the PostgreSQL 13.23 docs, and it's giving main character energy πŸ’…


πŸ’– NAME πŸ’–

REASSIGN_OWNED β€” change the ownership of database objects owned by a database role. no cap ✨


✨ SYNOPSIS ✨

REASSIGN OWNED BY { old_role | CURRENT_USER | SESSION_USER } [, ...]
               TO { new_role | CURRENT_USER | SESSION_USER }

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so REASSIGN OWNED instructs the system to change the ownership of database objects owned by any of the old_roles to new_role. that's the whole assignment, periodt 🫢


πŸŽ€ 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 πŸ’«
  • new_role β€” the name of the role that will be made the new owner of the affected objects. she's the new owner, slay πŸ‘‘

🌸 NOTES 🌸

  • REASSIGN OWNED is often used to prepare for the removal of one or more roles. it's giving cleanup era 🧹
  • 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. yes bestie, you gotta go database by database 😭
  • REASSIGN OWNED requires membership on both the source role(s) and the target role. both sides, no skipping 🫢
  • the DROP OWNED (DROP_OWNED(7)) command is an alternative that simply drops all the database objects owned by one or more roles. different vibe, same cleanup energy πŸ’€
  • 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 little caveat, iykyk ⚠️
  • see Section 21.4 for more discussion. there's more tea there β˜•

⭐ COMPATIBILITY ⭐

the REASSIGN OWNED command is a PostgreSQL extension. it's a PostgreSQL original, periodt 🌈


πŸ’… SEE ALSO πŸ’…


mwah πŸ’‹ this iconic page is from PostgreSQL 13.23, dated 2025, and it's serving REASSIGN OWNED(7) energy β€” byeee bestie πŸŽ€πŸ”₯

πŸ“¦ where this page comes from