CREATE SHADOW RULE
Description
The CREATE SHADOW RULE
syntax is used to create a shadow rule.
Syntax
Grammar Railroad diagram
CreateShadowRule ::=
'CREATE' 'SHADOW' 'RULE' ifNotExists? shadowRuleDefinition (',' shadowRuleDefinition)*
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
shadowRuleDefinition ::=
ruleName '(' storageUnitMapping shadowTableRule (',' shadowTableRule)* ')'
storageUnitMapping ::=
'SOURCE' '=' storageUnitName ',' 'SHADOW' '=' storageUnitName
shadowTableRule ::=
tableName '(' shadowAlgorithm ')'
shadowAlgorithm ::=
'TYPE' '(' 'NAME' '=' shadowAlgorithmType ',' propertiesDefinition ')'
ruleName ::=
identifier
storageUnitName ::=
identifier
tableName ::=
identifier
algorithmName ::=
identifier
shadowAlgorithmType ::=
string
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
key ::=
string
value ::=
literal
Supplement
- Duplicate
ruleName
cannot be created; storageUnitMapping
specifies the mapping relationship between thesource
database and the shadow library. You need to use the storage unit managed by RDL, please refer to STORAGE UNIT;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
andSQL_HINT
;ifNotExists
caluse is used for avoidDuplicate shadow rule
error.
Example
- Create a shadow rule
CREATE SHADOW RULE shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order(TYPE(NAME="SQL_HINT")),
t_order_item(TYPE(NAME="VALUE_MATCH", PROPERTIES("operation"="insert","column"="user_id", "value"='1')))
);
- Create a shadow rule with
ifNotExists
clause
CREATE SHADOW RULE IF NOT EXISTS shadow_rule(
SOURCE=demo_ds,
SHADOW=demo_ds_shadow,
t_order(TYPE(NAME="SQL_HINT")),
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 .