Changes row policy.
Syntax:
-- Rename: exactly one fully qualified policy (one name on one target).
-- RENAME TO may be combined with the same optional alteration clauses as below.
ALTER [ROW] POLICY [IF EXISTS] name
ON { [database.]table | database.* }
RENAME TO new_name
[ON CLUSTER cluster_name]
[AS {PERMISSIVE | RESTRICTIVE}]
[FOR SELECT]
[USING {condition | NONE}][,...]
[TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
-- Multiple names on one table target (no RENAME)
ALTER [ROW] POLICY [IF EXISTS] name [, ...]
[ON CLUSTER cluster_name]
ON { [database.]table | database.* }
[AS {PERMISSIVE | RESTRICTIVE}]
[FOR SELECT]
[USING {condition | NONE}][,...]
[TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
-- One name on multiple table targets (no RENAME)
ALTER [ROW] POLICY [IF EXISTS] name
[ON CLUSTER cluster_name]
ON { [database.]table | database.* } [, ...]
[AS {PERMISSIVE | RESTRICTIVE}]
[FOR SELECT]
[USING {condition | NONE}][,...]
[TO {role [,...] | ALL | ALL EXCEPT role [,...]}]
-- Mixed packing: each name paired with its own table target (no RENAME)
ALTER [ROW] POLICY [IF EXISTS]
name ON { [database.]table | database.* } [, name ON { [database.]table | database.* } ...]
[ON CLUSTER cluster_name]
[AS {PERMISSIVE | RESTRICTIVE}]
[FOR SELECT]
[USING {condition | NONE}][,...]
[TO {role [,...] | ALL | ALL EXCEPT role [,...]}]RENAME TO is only accepted when the statement names exactly one policy on one table target. Packed multi-name or multi-table lists cannot include RENAME TO — rename those policies in separate statements. On that single-policy form, RENAME TO can still be combined with other alterations such as AS, USING, and TO in the same statement.
Without RENAME TO, packing matches ParserRowPolicyNames: multiple names on one target, one name on multiple targets, or mixed name ON target pairs. Multi-name × multi-table (p1, p2 ON t1, t2) is not accepted. Optional ON CLUSTER applies once to the whole statement; run separate ALTER ROW POLICY statements when different clusters are required.
Examples:
-- Single-policy rename
ALTER ROW POLICY p1 ON db.table RENAME TO p1_new;
-- Rename plus other alterations on the same single policy
ALTER POLICY old_name ON db.table RENAME TO new_name USING id > 10;
-- Multiple names, one table
ALTER POLICY p1, p2 ON db.table TO ALL;
-- One name, multiple tables
ALTER POLICY p1 ON db.table, db.table2 USING NONE;
-- Mixed targets without rename
ALTER POLICY p1 ON db.table, p2 ON db2.table2 TO ALL;Part of: ALTER
Related: CREATE ROW POLICY, ALTER, SHOW