CREATE SHARDING ALGORITHM
Description
The CREATE SHARDING ALGORITHM
syntax is used to create a sharding algorithm for the currently selected database.
Syntax
CreateShardingAlgorithm ::=
'CREATE' 'SHARDING' 'ALGORITHM' shardingAlgorithmName '(' algorithmDefinition ')'
algorithmDefinition ::=
'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES' '(' propertyDefinition ')' )?')'
propertyDefinition ::=
( key '=' value ) ( ',' key '=' value )*
shardingAlgorithmName ::=
identifier
algorithmType ::=
string
Supplement
algorithmType
is the sharding algorithm type. For detailed sharding algorithm type information, please refer to Sharding Algorithm.
Example
1.Create sharding algorithms
-- create a sharding algorithm of type INLINE
CREATE SHARDING ALGORITHM inline_algorithm (
TYPE(NAME="inline", PROPERTIES("algorithm-expression"="t_order_${user_id % 2}"))
);
-- create a sharding algorithm of type AUTO_INTERVAL
CREATE SHARDING ALGORITHM interval_algorithm (
TYPE(NAME="auto_interval", PROPERTIES("datetime-lower"="2022-01-01 00:00:00", "datetime-upper"="2022-01-03 00:00:00", "sharding-seconds"="86400"))
);
Reserved word
CREATE
, SHARDING
, ALGORITHM
, TYPE
, NAME
, PROPERTIES
Related links
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .