复古 护眼 海天 深邃 暗黑 默认

CREATE READWRITE_SPLITTING RULE

描述

CREATE DEFAULT SINGLE TABLE RULE 语法用于创建读写分离规则

语法定义

CreateReadwriteSplittingRule ::=
  'CREATE' 'READWRITE_SPLITTING' 'RULE' readwriteSplittingDefinition ( ',' readwriteSplittingDefinition )*

readwriteSplittingDefinition ::=
  ruleName '(' ( staticReadwriteSplittingDefinition | dynamicReadwriteSplittingDefinition ) ( ',' loadBanlancerDefinition )? ')'

staticReadwriteSplittingDefinition ::=
    'WRITE_RESOURCE' '=' writeResourceName ',' 'READ_RESOURCES' '(' ruleName (',' ruleName)* ')'

dynamicReadwriteSplittingDefinition ::=
    'AUTO_AWARE_RESOURCE' '=' resourceName ( ',' 'WRITE_DATA_SOURCE_QUERY_ENABLED' '=' ('TRUE' | 'FALSE') )?

loadBanlancerDefinition ::=
    'TYPE' '(' 'NAME' '=' loadBanlancerType ( ',' 'PROPERTIES' '(' 'key' '=' 'value' ( ',' 'key' '=' 'value' )* ')' )? ')'

ruleName ::=
  identifier

writeResourceName ::=
  identifier

resourceName ::=
  identifier

补充说明

  • 支持创建静态读写分离规则和动态读写分离规则;
  • 动态读写分离规则依赖于数据库发现规则;
  • loadBanlancerType 指定负载均衡算法类型,请参考负载均衡算法;
  • 重复的 ruleName 将无法被创建。

示例

创建静态读写分离规则

CREATE READWRITE_SPLITTING RULE ms_group_0 (
    WRITE_RESOURCE=write_ds,
    READ_RESOURCES(read_ds_0,read_ds_1),
    TYPE(NAME="random")
);

创建动态读写分离规则

CREATE READWRITE_SPLITTING RULE ms_group_1 (
    AUTO_AWARE_RESOURCE=group_0,
    WRITE_DATA_SOURCE_QUERY_ENABLED=false,
    TYPE(NAME="random",PROPERTIES("read_weight"="2:1"))
);

保留字

CREATEREADWRITE_SPLITTINGRULEWRITE_RESOURCEREAD_RESOURCESAUTO_AWARE_RESOURCEWRITE_DATA_SOURCE_QUERY_ENABLEDTYPENAMEPROPERTIESTRUEFALSE

相关链接