CREATE SHADOW RULE

Description

The CREATE SHADOW RULE syntax is used to create a shadow rule.

Syntax

  1. CreateShadowRule ::=
  2. 'CREATE' 'SHADOW' 'RULE' shadowDefinition ( ',' shadowDefinition )*
  3. shadowDefinition ::=
  4. ruleName '(' resourceMapping shadowTableRule ( ',' shadowTableRule )* ')'
  5. resourceMapping ::=
  6. 'SOURCE' '=' resourceName ',' 'SHADOW' '=' resourceName
  7. shadowTableRule ::=
  8. tableName '(' shadowAlgorithm ( ',' shadowAlgorithm )* ')'
  9. shadowAlgorithm ::=
  10. ( algorithmName ',' )? 'TYPE' '(' 'NAME' '=' shadowAlgorithmType ',' 'PROPERTIES' '(' 'key' '=' 'value' ( ',' 'key' '=' 'value' ) ')'
  11. ruleName ::=
  12. identifier
  13. resourceName ::=
  14. identifier
  15. tableName ::=
  16. identifier
  17. algorithmName ::=
  18. identifier
  19. shadowAlgorithmType ::=
  20. string

Supplement

  • Duplicate ruleName cannot be created;
  • resourceMapping specifies the mapping relationship between the source database and the shadow library. You need to use the resource managed by RDL, please refer to resource;
  • shadowAlgorithm can act on multiple shadowTableRule at the same time;
  • If algorithmName is not specified, it will be automatically generated according to ruleName, tableName and shadowAlgorithmType;
  • shadowAlgorithmType currently supports VALUE_MATCH, REGEX_MATCH and SIMPLE_HINT.

Example

Create a shadow rule

  1. CREATE SHADOW RULE shadow_rule(
  2. SOURCE=demo_ds,
  3. SHADOW=demo_ds_shadow,
  4. t_order((simple_hint_algorithm, TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"="true", "foo"="bar"))),(TYPE(NAME="REGEX_MATCH", PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]')))),
  5. t_order_item((TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"='1'))))
  6. );

Reserved word

CREATE, SHADOW, RULE, SOURCE, SHADOW, TYPE, NAME, PROPERTIES