REASSIGN_OWNED(7pg16)

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

✨ REASSIGN OWNED ✨

okay so bestie, welcome to REASSIGN OWNED β€” it's a PostgreSQL 16 command and it's literally here to hand over ownership of database stuff from one role to another. It lives in section 7 of the manual (that's the pg16 one, iykyk), so like… administrative SQL energy, but make it friendly πŸ’…


πŸŽ€ NAME πŸŽ€

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

like, the whole vibe is: whose name is on this stuff? we're changing it. periodt.


✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So REASSIGN OWNED tells the system: hey, take every database object that's owned by any of the old_roles, and make new_role the owner instead. That's it. That's the whole assignment. slay πŸ’–


🌸 PARAMETERS 🌸

  • old_role β€” the name of a role. The ownership of all the objects inside the current database, plus all the shared objects (databases, tablespaces) owned by this role, gets reassigned to new_role. yes, all of them. no cap.
  • new_role β€” the name of the role that becomes the new owner of the affected objects. main character energy, honestly πŸ‘‘

πŸ’œ NOTES πŸ’œ

REASSIGN OWNED is often used to prep for removing one or more roles. But heads up bestie: because REASSIGN OWNED does not affect objects inside other databases, you'll usually need to run this command in each database that contains objects owned by the role you're trying to remove. like, every single one πŸ™ˆ

REASSIGN OWNED requires membership on both the source role(s) and the target role. both. don't skip leg day.

The DROP OWNED command is an alternative that just straight-up drops all the database objects owned by one or more roles. different vibe, same friend group πŸ’€

Also important: REASSIGN OWNED does not affect any privileges granted to the old_roles on objects they don't own. Likewise, it does not affect default privileges created with ALTER DEFAULT PRIVILEGES. If you wanna revoke those privileges, use DROP OWNED. fr fr.

See Section 22.4 for more discussion. yes, there's lore πŸ“–


🌈 COMPATIBILITY 🌈

The REASSIGN OWNED command is a PostgreSQL extension. homegrown, iconic, no notes ⭐


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie 🫢 brought to you by PostgreSQL 16.15, dated 2026 β€” go forth and reassign responsibly πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from