ALTER DEFAULT SHARDING STRATEGY

Description

The ALTER DEFAULT SHARDING STRATEGY syntax is used to alter a default sharding strategy

Syntax

  1. AlterDefaultShardingStrategy ::=
  2. 'ALTER' 'DEFAULT' 'SHARDING' ('DATABASE' | 'TABLE') 'STRATEGY' '(' shardingStrategy ')'
  3. shardingStrategy ::=
  4. 'TYPE' '=' strategyType ',' ( 'SHARDING_COLUMN' '=' columnName | 'SHARDING_COLUMNS' '=' columnNames ) ',' ( 'SHARDING_ALGORITHM' '=' algorithmName | algorithmDefinition )
  5. algorithmDefinition ::=
  6. 'TYPE' '(' 'NAME' '=' algorithmType ',' 'PROPERTIES' '(' propertyDefinition ')' ')'
  7. columnNames ::=
  8. columnName (',' columnName)+
  9. columnName ::=
  10. identifier
  11. algorithmName ::=
  12. identifier
  13. algorithmType ::=
  14. string

Supplement

  • When using the complex sharding algorithm, multiple sharding columns need to be specified using SHARDING_COLUMNS;
  • algorithmType is the sharding algorithm type. For detailed sharding algorithm type information, please refer to Sharding Algorithm.

Example

  • Alter a default sharding table strategy
  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. );

Reserved word

ALTER, DEFAULT, SHARDING, DATABASE, TABLE, STRATEGY, TYPE, SHARDING_COLUMN, SHARDING_COLUMNS, SHARDING_ALGORITHM, NAME, PROPERTIES