Shadow

Syntax

  1. CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
  2. ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
  3. DROP SHADOW RULE ruleName [, ruleName] ...
  4. DROP SHADOW ALGORITHM algorithmName [, algorithmName] ...
  5. CREATE DEFAULT SHADOW ALGORITHM shadowAlgorithm
  6. ALTER DEFAULT SHADOW ALGORITHM shadowAlgorithm
  7. DROP DEFAULT SHADOW ALGORITHM [IF EXISTS]
  8. SHOW DEFAULT SHADOW ALGORITHM
  9. SHOW SHADOW ALGORITHMS
  10. shadowRuleDefinition: ruleName(storageUnitMapping, shadowTableRule [, shadowTableRule] ...)
  11. storageUnitMapping: SOURCE=storageUnitName, SHADOW=storageUnitName
  12. shadowTableRule: tableName(shadowAlgorithm [, shadowAlgorithm] ...)
  13. shadowAlgorithm: TYPE(NAME=shadowAlgorithmType, PROPERTIES([algorithmProperties] ...))
  14. algorithmProperties: algorithmProperty [, algorithmProperty] ...
  15. algorithmProperty: key=value

Parameters Explained

nameDateTypeDescription
ruleNameIDENTIFIERRule name
storageUnitNameIDENTIFIERStorage unit name
tableNameIDENTIFIERShadow table name
algorithmNameIDENTIFIERShadow algorithm name
shadowAlgorithmTypeSTRINGShadow algorithm type

Notes

  • 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
  • shadowAlgorithmType currently supports VALUE_MATCH, REGEX_MATCH and SIMPLE_HINT
  • When executing ALTER SHADOW RULE, the corresponding shadowAlgorithm will not be removed
  • When creating shadow rule, algorithmName will be automatically generated according to ruleName, tableName, shadowAlgorithmType and algorithm collection index. The default name is default_shadow_algorithm.

Example

  1. CREATE SHADOW RULE shadow_rule(
  2. SOURCE=demo_ds,
  3. SHADOW=demo_ds_shadow,
  4. t_order(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. ALTER SHADOW RULE shadow_rule(
  7. SOURCE=demo_ds,
  8. SHADOW=demo_ds_shadow,
  9. t_order(TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=true, "foo"="bar")),TYPE(NAME="REGEX_MATCH", PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]'))),
  10. t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"=1))));
  11. DROP SHADOW RULE shadow_rule;
  12. DROP SHADOW ALGORITHM simple_hint_algorithm;
  13. CREATE DEFAULT SHADOW ALGORITHM TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=true, "foo"="bar"));
  14. ALTER DEFAULT SHADOW ALGORITHM TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=false, "foo"="bar"));
  15. SHOW DEFAULT SHADOW ALGORITHM;
  16. DROP DEFAULT SHADOW ALGORITHM;