CREATE READWRITE_SPLITTING RULE
Description
The CREATE READWRITE_SPLITTING RULE
syntax is used to create a read/write splitting rule.
Syntax
Grammar Railroad diagram
CreateReadwriteSplittingRule ::=
'CREATE' 'READWRITE_SPLITTING' 'RULE' ifNotExists? readwriteSplittingDefinition (',' readwriteSplittingDefinition)*
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
readwriteSplittingDefinition ::=
ruleName '(' dataSourceDefinition (',' transactionalReadQueryStrategyDefinition)? (',' loadBalancerDefinition)? ')'
dataSourceDefinition ::=
'WRITE_STORAGE_UNIT' '=' writeStorageUnitName ',' 'READ_STORAGE_UNITS' '(' storageUnitName (',' storageUnitName)* ')'
transactionalReadQueryStrategyDefinition ::=
'TRANSACTIONAL_READ_QUERY_STRATEGY' '=' transactionalReadQueryStrategyType
loadBalancerDefinition ::=
'TYPE' '(' 'NAME' '=' loadBalancerType (',' propertiesDefinition)? ')'
ruleName ::=
identifier
writeStorageUnitName ::=
identifier
storageUnitName ::=
identifier
transactionalReadQueryStrategyType ::=
string
loadBalancerType ::=
string
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
key ::=
string
value ::=
literal
Note
transactionalReadQueryStrategyType
specifies the routing strategy for read query within a transaction, please refer to YAML configuration;loadBalancerType
specifies the load balancing algorithm type, please refer to Load Balance Algorithm;- Duplicate
ruleName
will not be created; ifNotExists
clause used to avoid theDuplicate readwrite_splitting rule
error.
Example
Create a read/write splitting rule
CREATE READWRITE_SPLITTING RULE ms_group_0 (
WRITE_STORAGE_UNIT=write_ds,
READ_STORAGE_UNITS(read_ds_0,read_ds_1),
TYPE(NAME="random")
);
Create read/write splitting rule with the ifNotExists
clause
- read/write splitting rule
CREATE READWRITE_SPLITTING RULE IF NOT EXISTS ms_group_0 (
WRITE_STORAGE_UNIT=write_ds,
READ_STORAGE_UNITS(read_ds_0,read_ds_1),
TYPE(NAME="random")
);
Reserved words
CREATE
, READWRITE_SPLITTING
, RULE
, WRITE_STORAGE_UNIT
, READ_STORAGE_UNITS
, TYPE
, NAME
, PROPERTIES
, TRUE
, FALSE
Related links
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .