CREATE SHADOW RULE

Description

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

Syntax

Grammar Railroad diagram

  1. CreateShadowRule ::=
  2. 'CREATE' 'SHADOW' 'RULE' ifNotExists? shadowRuleDefinition (',' shadowRuleDefinition)*
  3. ifNotExists ::=
  4. 'IF' 'NOT' 'EXISTS'
  5. shadowRuleDefinition ::=
  6. ruleName '(' storageUnitMapping shadowTableRule (',' shadowTableRule)* ')'
  7. storageUnitMapping ::=
  8. 'SOURCE' '=' storageUnitName ',' 'SHADOW' '=' storageUnitName
  9. shadowTableRule ::=
  10. tableName '(' shadowAlgorithm ')'
  11. shadowAlgorithm ::=
  12. 'TYPE' '(' 'NAME' '=' shadowAlgorithmType ',' propertiesDefinition ')'
  13. ruleName ::=
  14. identifier
  15. storageUnitName ::=
  16. identifier
  17. tableName ::=
  18. identifier
  19. algorithmName ::=
  20. identifier
  21. shadowAlgorithmType ::=
  22. string
  23. propertiesDefinition ::=
  24. 'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
  25. key ::=
  26. string
  27. value ::=
  28. literal

Supplement

  • Duplicate ruleName cannot be created;
  • storageUnitMapping specifies the mapping relationship between the source database and the shadow library. You need to use the storage unit managed by RDL, please refer to STORAGE UNIT;
  • 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 SQL_HINT;
  • ifNotExists caluse is used for avoid Duplicate shadow rule error.

Example

  • Create a shadow rule
  1. CREATE SHADOW RULE shadow_rule(
  2. SOURCE=demo_ds,
  3. SHADOW=demo_ds_shadow,
  4. t_order(TYPE(NAME="SQL_HINT")),
  5. t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"='1')))
  6. );
  • Create a shadow rule with ifNotExists clause
  1. CREATE SHADOW RULE IF NOT EXISTS shadow_rule(
  2. SOURCE=demo_ds,
  3. SHADOW=demo_ds_shadow,
  4. t_order(TYPE(NAME="SQL_HINT")),
  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