CREATE SHARDING KEY GENERATOR
Description
The CREATE SHARDING KEY GENERATOR syntax is used to create an independent sharding key generator for the currently selected database.
Syntax
CreateShardingKeyGenerator ::=
'CREATE' 'SHARDING' 'KEY' 'GENERATOR' ifNotExists? keyGeneratorName '(' algorithmDefinition ')'
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
algorithmDefinition ::=
'TYPE' '(' 'NAME' '=' algorithmType (',' propertiesDefinition)? ')'
propertiesDefinition ::=
'PROPERTIES' '(' (key '=' value (',' key '=' value)*)? ')'
key ::=
string
value ::=
literal
keyGeneratorName ::=
identifier
algorithmType ::=
stringSupplement
keyGeneratorNameis the name of the independent sharding key generator;algorithmDefinitiondefines the key generator algorithm and its properties;algorithmTypeis the key generation algorithm type. For details, refer to Distributed Primary Key;ifNotExistsclause is used to avoidDuplicate sharding key generatorerror.
Example
- Create a sharding key generator
CREATE SHARDING KEY GENERATOR snowflake_generator (
TYPE(NAME="SNOWFLAKE",PROPERTIES("worker-id"=1))
);- Create a sharding key generator with
ifNotExistsclause
CREATE SHARDING KEY GENERATOR IF NOT EXISTS snowflake_generator (
TYPE(NAME="SNOWFLAKE")
);Reserved word
CREATE, SHARDING, KEY, GENERATOR, IF, NOT, EXISTS, TYPE, NAME, PROPERTIES