ALTER_POLICY(7)

๐Ÿ‘‘ ALTER POLICY ๐Ÿ’…

okay bestie, so this is the PostgreSQL 18.6 Documentation page for ALTER POLICY, and it's genuinely one of my faves because it's short and it does exactly one thing. no notes. โœจ


โœจ NAME โœจ

ALTER_POLICY โ€” change the definition of a row-level security policy ๐ŸŽ€


๐ŸŒธ 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 ) ]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

So. ALTER POLICY changes the definition of an existing row-level security policy. that's it, that's the job. ๐Ÿซถ

but like โ€” listen โ€” ALTER POLICY only lets you modify two-ish things:

  • the set of roles the policy applies to
  • the USING expression
  • the WITH CHECK expression

and that's the whole menu. if you wanna change other properties of a policy โ€” like the command it applies to, or whether it's permissive or restrictive โ€” the policy must be dropped and recreated. no shortcuts, no glow-up, it's giving delete-and-repost. ๐Ÿ˜ญ

also, to use ALTER POLICY, you must own the table that the policy applies to. ownership check, no cap. ๐Ÿ‘‘

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 stays unchanged โ€” like, it just chills there, untouched. main character energy for real. ๐Ÿ’…


๐Ÿฆ‹ PARAMETERS ๐Ÿฆ‹

  • name โ€” the name of an existing policy to alter. gotta exist, bestie, we're not manifesting here.
  • table_name โ€” the name (optionally schema-qualified) of the table that the policy is on.
  • new_name โ€” the new name for the policy. rebrand era โœจ
  • role_name โ€” the role(s) to which the policy applies. Multiple roles can be specified at one time. To apply the policy to all roles, use PUBLIC. everyone's invited, it's a party ๐ŸŒˆ
  • 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. not standard SQL, it's our little thing, iykyk ๐Ÿ’œ


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


lowkey reminder: if you can't change it here, you gotta DROP it and make a whole new one. dramatic? yes. correct? also yes. ๐Ÿ’€

mwah โ€” this was PostgreSQL 18.6, dated 2026. go own your tables and slay your policies, bestie ๐Ÿงšโญ๐Ÿ’–