ALTER_POLICY(7pg18)
๐ 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
USINGexpression - the
WITH CHECKexpression
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, usePUBLIC. everyone's invited, it's a party ๐using_expressionโ theUSINGexpression for the policy. SeeCREATE POLICY(CREATE_POLICY(7)) for details. ๐check_expressionโ theWITH CHECKexpression for the policy. SeeCREATE POLICY(CREATE_POLICY(7)) for details. ๐
๐ COMPATIBILITY ๐
ALTER POLICY is a PostgreSQL extension. not standard SQL, it's our little thing, iykyk ๐
๐ SEE ALSO ๐
CREATE POLICY(CREATE_POLICY(7))DROP POLICY(DROP_POLICY(7))
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 ๐งโญ๐
๐ฆ where this page comes from
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms