ALTER_SCHEMA(7pg17)

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

πŸ’… ALTER SCHEMA β€” the ALTER_SCHEMA(7pg17) glow-up, PostgreSQL 17.11 edition

okay so bestie, welcome to the ALTER_SCHEMA page. this is the one where you change the definition of a schema β€” think of it as a schema makeover, not a whole new schema. ✨


✨ SYNOPSIS ✨

ALTER SCHEMA name RENAME TO new_name
ALTER SCHEMA name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }

that's it. two moves. rename it or hand it to someone else. iconic, lowkey minimal. πŸŽ€


🌸 DESCRIPTION 🌸

so ALTER SCHEMA changes the definition of a schema. that's the whole thing. short and sweet, fr fr. πŸ¦‹

now here's the part where you actually have to have the receipts:

  • You must own the schema to use ALTER SCHEMA. no ownership, no glow-up. πŸ’…
  • To rename a schema you must also have the CREATE privilege for the database.
  • To alter the owner, you must be able to SET ROLE to the new owning role, and that role must have the CREATE privilege for the database.
and yes β€” superusers have all these privileges automatically, so if you're the main character with superuser energy, you're chilling. πŸ‘‘

🧚 PARAMETERS 🧚

  • name β€” the name of an existing schema. like, it has to already exist, bestie, we can't rename a vibe that isn't there. πŸ’€
  • new_name β€” the new name of the schema. and here's the catch: the new name cannot begin with pg_, because those names are reserved for system schemas. so pg_my_slay_schema? not happening. πŸ™ˆ
  • new_owner β€” the new owner of the schema. hand it over, it's theirs now. 🫢

🌈 COMPATIBILITY 🌈

there is no ALTER SCHEMA statement in the SQL standard. so if someone asks "is this standard SQL?" β€” nope, not even a little. it's giving PostgreSQL exclusive. 😭


πŸ‘‘ SEE ALSO πŸ‘‘

the holy trinity: make it, alter it, drop it. periodt. πŸ”₯


⭐ lil reminder before you go: you need ownership to alter, CREATE on the database to rename, and SET ROLE + CREATE to change the owner. don't skip the vibe check on privileges or the server will simply say no. πŸ’œ

that's the whole page, bestie β€” you ate. πŸ’–

this one's from the PostgreSQL 17.11 docs, dated 2026. go be iconic with your schemas. βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from