ALTER_POLICY(7pg17)

πŸ“¦ version 17.11, in opensuse-leap 16.0

🌸 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, use PUBLIC. Group-chat invite list, basically. πŸ’Œ
  • 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. Very PostgreSQL-coded of it. πŸ’œ


πŸ”₯ SEE ALSO πŸ”₯


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