CREATE MASK RULE
语法用于创建数据脱敏规则。
CreateMaskRule ::=
'CREATE' 'MASK' 'RULE' ifNotExists? maskRuleDefinition (',' maskRuleDefinition)*
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
maskRuleDefinition ::=
ruleName '(' 'COLUMNS' '(' columnDefinition (',' columnDefinition)* ')' ')'
columnDefinition ::=
'(' 'NAME' '=' columnName ',' maskAlgorithmDefinition ')'
maskAlgorithmDefinition ::=
'TYPE' '(' 'NAME' '=' algorithmType (',' propertiesDefinition)? ')'
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
ruleName ::=
identifier
columnName ::=
identifier
algorithmType ::=
literal
key ::=
string
value ::=
literal
algorithmType
指定数据脱敏算法类型,请参考 数据脱敏算法;ruleName
将无法被创建;ifNotExists
子句用于避免出现 Duplicate mask rule
错误。CREATE MASK RULE t_mask (
COLUMNS(
(NAME=phone_number,TYPE(NAME='MASK_FROM_X_TO_Y', PROPERTIES("from-x"=1, "to-y"=2, "replace-char"="*"))),
(NAME=address,TYPE(NAME='MD5'))
));
ifNotExists
子句创建数据脱敏规则CREATE MASK RULE IF NOT EXISTS t_mask (
COLUMNS(
(NAME=phone_number,TYPE(NAME='MASK_FROM_X_TO_Y', PROPERTIES("from-x"=1, "to-y"=2, "replace-char"="*"))),
(NAME=address,TYPE(NAME='MD5'))
));
CREATE
、MASK
、RULE
、COLUMNS
、NAME
、TYPE