数据仓库服务 GAUSSDB(DWS)-ALTER REDACTION POLICY:示例

时间:2024-12-06 15:12:40

示例

修改脱敏策略生效表达式,使其对指定角色生效(若不指定用户,默认对当前用户生效):

1
2
ALTER REDACTION POLICY mask_emp ON emp WHEN (pg_has_role(current_user, 'redact_role', 'member'));
ALTER REDACTION POLICY mask_emp ON emp WHEN (pg_has_role('redact_role', 'member'));

修改脱敏策略生效表达式,使其对所有用户均生效:

1
ALTER REDACTION POLICY mask_emp ON emp WHEN (1=1);

修改脱敏策略,使其失效:

1
ALTER REDACTION POLICY mask_emp ON emp DISABLE;

重新使脱敏策略生效:

1
ALTER REDACTION POLICY mask_emp ON emp ENABLE;

重命名脱敏策略为mask_emp_new:

1
ALTER REDACTION POLICY mask_emp ON emp RENAME TO mask_emp_new;

新增脱敏列:

1
ALTER REDACTION POLICY mask_emp_new ON emp ADD COLUMN name WITH mask_partial(name, '*', 1, length(name));

修改脱敏列name,采用脱敏函数MASK_FULL对name字段数据全脱敏:

1
ALTER REDACTION POLICY mask_emp_new ON emp MODIFY COLUMN name WITH mask_full(name);

删除已存在的脱敏列:

1
ALTER REDACTION POLICY mask_emp_new ON emp DROP COLUMN name;
support.huaweicloud.com/sqlreference-910-dws/dws_06_0132.html