ALTER_POLICY(7pg15)
π ALTER POLICY π
okay so bestie, welcome to the ALTER POLICY page from the PostgreSQL 15.19 Documentation β yes that's the manual we're in, ALTER POLICY(7), and no we are not skipping anything, we're gonna read it together π«Ά
β¨ NAME β¨
ALTER POLICY β change the definition of a row-level security policy. that's it, that's the vibe. you're editing a policy that already exists, not making a new one π
πΈ 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 forms, both iconic, pick your fighter π
π DESCRIPTION π
so ALTER POLICY changes the definition of an existing row-level security policy. but listen β it's lowkey restrictive: ALTER POLICY only lets you modify the set of roles the policy applies to, plus the USING and WITH CHECK expressions. that's the whole menu, bestie π
want to change literally anything else about a policy β like which command it applies to, or whether it's permissive or restrictive? then you gotta DROP it and recreate it. no shortcuts, no glow-ups, periodt π
to use ALTER POLICY, you must own the table that the policy applies to. own the table, get the keys π
now, in the second form of ALTER POLICY, the role list, using_expression, and check_expression are replaced independently if specified. and when one of those clauses is omitted? the corresponding part of the policy stays exactly as it was. untouched. unbothered. main character energy π
π PARAMETERS π
nameβ the name of an existing policy you wanna alter. it's gotta exist already, we're not manifesting here β¨table_nameβ the name (optionally schema-qualified) of the table that the policy is on. schema-qualified if you're feeling fancy πnew_nameβ the new name for the policy. rebrand, slay π¦role_nameβ the role(s) to which the policy applies. you can specify multiple roles at one time, love a group chat. and to apply the policy to all roles, usePUBLICπusing_expressionβ theUSINGexpression for the policy. seeCREATE POLICY(CREATE_POLICY(7)) for the deets πcheck_expressionβ theWITH CHECKexpression for the policy. also seeCREATE POLICY(CREATE_POLICY(7)) for the deets π
π§ COMPATIBILITY π§
ALTER POLICY is a PostgreSQL extension. it's giving homegrown, it's giving original, no cap πΈ
β SEE ALSO β
CREATE POLICY(CREATE_POLICY(7))DROP POLICY(DROP_POLICY(7))
read those too, bestie, they're the whole friend group π₯
fr fr though β if you're here to change anything besides roles,USING, orWITH CHECK, go readDROP POLICY/CREATE POLICYfirst, becauseALTER POLICYwill not do it for you π
k that's the whole page, you ate that π mwah π β signed, sealed, delivered straight from PostgreSQL 15.19, dated 2026, ALTER POLICY(7) forever π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql15 15.19-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms