ALTER_POLICY(7pg14)

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

πŸ’… ALTER POLICY β€” the ALTER_POLICY page, but make it make sense

okay bestie so this is the ALTER POLICY page from the PostgreSQL 14.24 Documentation (7pg14), and it's literally about changing the definition of a row-level security policy. that's it, that's the vibe. let's get into it πŸŽ€


✨ NAME ✨

ALTER POLICY β€” change the definition of a row-level security policy. yes queen, we're editing policies today πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

ALTER POLICY name ON table_name RENAME TO new_name

ALTER POLICY name ON table_name
    [ TO { role_name | PUBLIC | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] ]
    [ USING ( using_expression ) ]
    [ WITH CHECK ( check_expression ) ]

two whole forms, both iconic, both copy-pasteable. keep those brackets exactly where they are, they're load-bearing πŸ’…


🌸 DESCRIPTION 🌸

ALTER POLICY changes the definition of an existing row-level security policy. like, it edits a policy that's already out there living its life.

⚠️ huge heads up: ALTER POLICY only lets you modify the set of roles to which the policy applies and the USING and WITH CHECK expressions. that's the whole menu, no substitutions.

so if you wanna change other properties of a policy β€” like which command it applies to, or whether it's permissive or restrictive β€” the policy must be dropped and recreated. no in-place glow-up for those, sorry bestie 😭 you're doing a full rebuild.

to use ALTER POLICY, you must own the table that the policy applies to. no ownership, no edits. periodt.

and here's the cute part β€” in the second form of ALTER POLICY, the role list, using_expression, and check_expression are replaced independently if specified. when one of those clauses is omitted, the corresponding part of the policy is unchanged. so you can tweak one thing and leave the rest exactly as it was 🫢


πŸ’– PARAMETERS πŸ’–

  • name β€” the name of an existing policy to alter. yep, the one you're editing. the main character of this operation πŸ‘‘
  • table_name β€” the name (optionally schema-qualified) of the table that the policy is on. schema-qualify it if you're being extra, we support you ✨
  • new_name β€” the new name for the policy. that's the rename arc πŸ’«
  • role_name β€” the role(s) to which the policy applies. multiple roles can be specified at one time, so go off, bring the whole group chat. to apply the policy to all roles, use PUBLIC 🌈
  • using_expression β€” the USING expression for the policy. see CREATE POLICY (CREATE_POLICY(7)) for details πŸ“–
  • check_expression β€” the WITH CHECK expression for the policy. see CREATE POLICY (CREATE_POLICY(7)) for details πŸ“–

🧚 COMPATIBILITY 🧚

ALTER POLICY is a PostgreSQL extension. it's giving homegrown, it's giving proprietary flavor, and honestly? we love that for us πŸ’œ


πŸ”₯ SEE ALSO πŸ”₯

  • CREATE POLICY (CREATE_POLICY(7)) β€” where policies are born 🐣
  • DROP POLICY (DROP_POLICY(7)) β€” where policies go to be recreated, since remember, some changes require exactly this 😭

okay that's the whole page, no cap. this was PostgreSQL 14.24, dated 2026, and your girl is out β€” go own that table and edit those policies responsibly, bestie πŸ’…πŸ“πŸŽ€

πŸ“¦ where this page comes from