Sharding
- needs to use data source resources managed by RDL
shardingAlgorithmType
specifies the type of automatic sharding algorithm, please refer to Auto Sharding AlgorithmkeyGenerateStrategyType
specifies the distributed primary key generation strategy, please refer to auditorAlgorithmType
specifies the sharding audit strategy, please refer to Sharding Audit Algorithm;- Duplicate
tableName
will not be created shardingAlgorithm
can be reused by different Sharding Table Rule
, so when executing DROP SHARDING TABLE RULE
, the corresponding shardingAlgorithm
will not be removed- To remove
shardingAlgorithm
, please execute DROP SHARDING ALGORITHM
strategyType
specifies the sharding strategy, please refer toSharding Table Rule
supports both Auto Table
and Table
at the same time. The two types are different in syntax. For the corresponding configuration file, please refer to Sharding- When using the
autoCreativeAlgorithm
way to specify shardingStrategy
, a new sharding algorithm will be created automatically. The algorithm naming rule is tableName_strategyType_shardingAlgorithmType
, such as t_order_database_inline
Sharding Binding Table Rule
CREATE SHARDING BINDING TABLE RULES bindTableRulesDefinition [, bindTableRulesDefinition] ...
ALTER SHARDING BINDING TABLE RULES bindTableRulesDefinition [, bindTableRulesDefinition] ...
DROP SHARDING BINDING TABLE RULES bindTableRulesDefinition [, bindTableRulesDefinition] ...
bindTableRulesDefinition:
(tableName [, tableName] ... )
ALTER
will overwrite the binding table configuration in the database with the new configuration
CREATE SHARDING BROADCAST TABLE RULES (tableName [, tableName] ... )
ALTER SHARDING BROADCAST TABLE RULES (tableName [, tableName] ... )
DROP SHARDING BROADCAST TABLE RULES
ALTER
will overwrite the broadcast table configuration in the database with the new configuration
Example
Sharding Table Rule
CREATE SHARDING AUDITOR sharding_key_required_auditor (
TYPE(NAME="DML_SHARDING_CONDITIONS")
);
ALTER SHARDING AUDITOR sharding_key_required_auditor (
TYPE(NAME="DML_SHARDING_CONDITIONS")
);
DROP SHARDING AUDITOR IF EXISTS sharding_key_required_auditor;
CREATE SHARDING TABLE RULE t_order (
RESOURCES(resource_0,resource_1),
SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="4")),
KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
ALTER SHARDING TABLE RULE t_order (
RESOURCES(resource_0,resource_1,resource_2,resource_3),
SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="16")),
KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
AUDIT_STRATEGY(AUDITORS=[auditor1,auditor2],ALLOW_HINT_DISABLE=true)
);
DROP SHARDING TABLE RULE t_order;
DROP SHARDING ALGORITHM t_order_hash_mod;
CREATE SHARDING BINDING TABLE RULES (t_order,t_order_item),(t_1,t_2);
ALTER SHARDING BINDING TABLE RULES (t_order,t_order_item);
DROP SHARDING BINDING TABLE RULES;
DROP SHARDING BINDING TABLE RULES (t_order,t_order_item);
Sharding Broadcast Table Rule
CREATE SHARDING BROADCAST TABLE RULES (t_b,t_a);
ALTER SHARDING BROADCAST TABLE RULES (t_b,t_a,t_3);
DROP SHARDING BROADCAST TABLE RULES;