Shadow
Syntax
CREATE SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
ALTER SHADOW RULE shadowRuleDefinition [, shadowRuleDefinition] ...
DROP SHADOW RULE ruleName [, ruleName] ...
DROP SHADOW ALGORITHM algorithmName [, algorithmName] ...
CREATE DEFAULT SHADOW ALGORITHM shadowAlgorithm
ALTER DEFAULT SHADOW ALGORITHM shadowAlgorithm
DROP DEFAULT SHADOW ALGORITHM [IF EXISTS]
SHOW DEFAULT SHADOW ALGORITHM
SHOW SHADOW ALGORITHMS
shadowRuleDefinition: ruleName(storageUnitMapping, shadowTableRule [, shadowTableRule] ...)
storageUnitMapping: SOURCE=storageUnitName, SHADOW=storageUnitName
shadowTableRule: tableName(shadowAlgorithm [, shadowAlgorithm] ...)
shadowAlgorithm: TYPE(NAME=shadowAlgorithmType, PROPERTIES([algorithmProperties] ...))
algorithmProperties: algorithmProperty [, algorithmProperty] ...
algorithmProperty: key=value
Parameters Explained
name | DateType | Description |
---|---|---|
ruleName | IDENTIFIER | Rule name |
storageUnitName | IDENTIFIER | Storage unit name |
tableName | IDENTIFIER | Shadow table name |
algorithmName | IDENTIFIER | Shadow algorithm name |
shadowAlgorithmType | STRING | Shadow 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 thestorage unit
managed by RDL, please refer to storage unitshadowAlgorithmType
currently supportsVALUE_MATCH
,REGEX_MATCH
andSIMPLE_HINT
- When executing
ALTER SHADOW RULE
, the correspondingshadowAlgorithm
will not be removed - When creating shadow rule,
algorithmName
will be automatically generated according toruleName
,tableName
,shadowAlgorithmType
and algorithm collection index. The default name isdefault_shadow_algorithm
.
Example
CREATE SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order(TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=true, "foo"="bar")),TYPE(NAME="REGEX_MATCH", PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]'))),
t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"=1))));
ALTER SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order(TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=true, "foo"="bar")),TYPE(NAME="REGEX_MATCH", PROPERTIES("operation"="insert","column"="user_id", "regex"='[1]'))),
t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"=1))));
DROP SHADOW RULE shadow_rule;
DROP SHADOW ALGORITHM simple_hint_algorithm;
CREATE DEFAULT SHADOW ALGORITHM TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=true, "foo"="bar"));
ALTER DEFAULT SHADOW ALGORITHM TYPE(NAME="SIMPLE_HINT", PROPERTIES("shadow"=false, "foo"="bar"));
SHOW DEFAULT SHADOW ALGORITHM;
DROP DEFAULT SHADOW ALGORITHM;
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .