ALTER_POLICY(7pg14)
π
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 POLICYonly lets you modify the set of roles to which the policy applies and theUSINGandWITH CHECKexpressions. 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, usePUBLICπ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. 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
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql14 14.24-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