ALTER_POLICY(7pg16)

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

πŸ’… ALTER_POLICY (7pg16) β€” like, the whole glow-up guide for row-level security policies

okay bestie, so this page is ALTER POLICY from the PostgreSQL 16.15 docs and it's literally the manual for changing up a row-level security policy you already made. no cap, it's shorter than you'd think, but every single detail matters, so let's go πŸŽ€


✨ SYNOPSIS ✨

here's the shape of it β€” two forms, both iconic:

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 ) ]

like, the square brackets are optional bits, the curly braces are "pick one of these", and that [, ...] means "and you can keep adding more, queen". πŸ‘‘


🌸 DESCRIPTION 🌸

okay so ALTER POLICY changes the definition of an existing row-level security policy. it's giving "makeover, not rebirth" β€” because, and this is the key part, ALTER POLICY only lets you modify:

  • the set of roles the policy applies to, and
  • the USING and WITH CHECK expressions.

that's it, that's the whole menu. if you wanna change other properties of a policy β€” like which command it applies to, or whether it's permissive or restrictive β€” the policy has to be dropped and recreated. yeah, i know, annoying, but that's the rule. πŸ’€

to use ALTER POLICY, you must own the table that the policy applies to. no ownership, no edits. sorry babe. πŸ™ˆ

now, in that second form of ALTER POLICY, the role list, using_expression, and check_expression each get replaced independently if you specify them. so if you omit one of those clauses, the corresponding part of the policy just stays exactly how it was. nothing gets wiped by accident, slay. ✨


πŸ’œ PARAMETERS πŸ’œ

  • name β€” the name of an existing policy you wanna alter. literally the one you're editing.
  • table_name β€” the name of the table the policy is on. it can be optionally schema-qualified, so go ahead and be specific if you need to be.
  • new_name β€” the new name for the policy. fresh name, same vibe.
  • role_name β€” the role(s) the policy applies to. you can specify multiple roles at one time, no problem. and if you want it to apply to all roles, just use PUBLIC.
  • using_expression β€” the USING expression for the policy. for the full deets, see CREATE POLICY (CREATE_POLICY(7)).
  • check_expression β€” the WITH CHECK expression for the policy. again, CREATE POLICY (CREATE_POLICY(7)) has the details.

πŸ¦‹ COMPATIBILITY πŸ¦‹

ALTER POLICY is a PostgreSQL extension. so like, it's a Postgres original, not a standard-SQL thing. iykyk πŸ’…


🌈 SEE ALSO 🌈


🫢 and that's the whole page, bestie! written to match PostgreSQL 16.15, dated 2026, and filed under ALTER POLICY(7) β€” go forth and alter those policies, main character. πŸ’–β­

πŸ“¦ where this page comes from