CREATE SHADOW RULE
Description
The CREATE SHADOW RULE
syntax is used to create a shadow rule.
Syntax
CreateShadowRule ::=
'CREATE' 'SHADOW' 'RULE' shadowDefinition ( ',' shadowDefinition )*
shadowDefinition ::=
ruleName '(' resourceMapping shadowTableRule ( ',' shadowTableRule )* ')'
resourceMapping ::=
'SOURCE' '=' resourceName ',' 'SHADOW' '=' resourceName
shadowTableRule ::=
tableName '(' shadowAlgorithm ( ',' shadowAlgorithm )* ')'
shadowAlgorithm ::=
( algorithmName ',' )? 'TYPE' '(' 'NAME' '=' shadowAlgorithmType ',' 'PROPERTIES' '(' 'key' '=' 'value' ( ',' 'key' '=' 'value' ) ')'
ruleName ::=
identifier
resourceName ::=
identifier
tableName ::=
identifier
algorithmName ::=
identifier
shadowAlgorithmType ::=
string
Supplement
- Duplicate
ruleName
cannot be created; resourceMapping
specifies the mapping relationship between thesource
database and the shadow library. You need to use the resource managed by RDL, please refer to resource;shadowAlgorithm
can act on multipleshadowTableRule
at the same time;- If
algorithmName
is not specified, it will be automatically generated according toruleName
,tableName
andshadowAlgorithmType
; shadowAlgorithmType
currently supportsVALUE_MATCH
,REGEX_MATCH
andSIMPLE_HINT
.
Example
Create a shadow rule
CREATE SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
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]')))),
t_order_item((TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"='1'))))
);
Reserved word
CREATE
, SHADOW
, RULE
, SOURCE
, SHADOW
, TYPE
, NAME
, PROPERTIES
Related links
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .