ALTER DEFAULT SHARDING STRATEGY

描述

ALTER DEFAULT SHARDING STRATEGY 语法用于修改默认的分片策略

语法定义

语法 铁路图

  1. AlterDefaultShardingStrategy ::=
  2. 'ALTER' 'DEFAULT' 'SHARDING' ('DATABASE' | 'TABLE') 'STRATEGY' '(' shardingStrategy ')'
  3. shardingStrategy ::=
  4. 'TYPE' '=' strategyType ',' ('SHARDING_COLUMN' '=' columnName | 'SHARDING_COLUMNS' '=' columnNames) ',' 'SHARDING_ALGORITHM' '=' algorithmDefinition
  5. strategyType ::=
  6. string
  7. algorithmDefinition ::=
  8. 'TYPE' '(' 'NAME' '=' algorithmType ',' propertiesDefinition ')'
  9. columnNames ::=
  10. columnName (',' columnName)+
  11. columnName ::=
  12. identifier
  13. algorithmType ::=
  14. string
  15. propertiesDefinition ::=
  16. 'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
  17. key ::=
  18. string
  19. value ::=
  20. literal

补充说明

  • 当使用复合分片算法时,需要通过 SHARDING_COLUMNS 指定多个分片键;
  • algorithmType 为分片算法类型,详细的分片算法类型信息请参考分片算法

示例

  • 修改默认分表策略
  1. ALTER DEFAULT SHARDING TABLE STRATEGY (
  2. TYPE="standard", SHARDING_COLUMN=user_id, SHARDING_ALGORITHM(TYPE(NAME=inline, PROPERTIES("algorithm-expression"="t_order_${user_id % 2}")))
  3. );

保留字

ALTERDEFAULTSHARDINGDATABASETABLESTRATEGYTYPESHARDING_COLUMNSHARDING_COLUMNSSHARDING_ALGORITHMNAMEPROPERTIES

相关链接