ALTER_POLICY(7pg17)
πΈ NAME πΈ
Okay bestie, so ALTER_POLICY β aka the ALTER POLICY(7) page β is literally the glow-up command for changing the definition of a row-level security policy. No cap. π
β¨ 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 π¦
ALTER POLICY changes the definition of an existing row-level security policy. Itβs giving βsmall edits only,β though, so listen up: ALTER POLICY only allows the set of roles to which the policy applies and the USING and WITH CHECK expressions to be modified. Thatβs the whole menu. π
To change other properties of a policy β like the command to which it applies or whether it is permissive or restrictive β the policy must be dropped and recreated. No sneaky side-door edits, bestie. π
To use ALTER POLICY, you must own the table that the policy applies to. Owner energy only, periodt. π
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 if you skip a clause, it stays exactly as it was β iconic βno thoughts, just untouchedβ behaviour. π«Ά
π PARAMETERS π
nameβ the name of an existing policy to alter. The main character policy, in other words. πtable_nameβ the name (optionally schema-qualified) of the table that the policy is on. Yes, schema-qualified is allowed, iykyk. π§new_nameβ the new name for the policy. Rename era unlocked. β¨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. Group-chat invite list, basically. π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. Very PostgreSQL-coded of it. π
π₯ SEE ALSO π₯
CREATE POLICY(CREATE_POLICY(7))DROP POLICY(DROP_POLICY(7))
And thatβs the page, bestie β sourced from PostgreSQL 17.11, dated 2026, and signed off with maximum sparkle. Mwah. πππ¦
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-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