Sharding

    • needs to use storage units managed by RDL
    • shardingAlgorithmType specifies the type of automatic sharding algorithm, please refer to Auto Sharding Algorithm
    • keyGenerateStrategyType 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
    • To remove shardingAlgorithm, please execute DROP SHARDING ALGORITHM
    • strategyType specifies the sharding strategy, please refer to
    • Sharding 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
    • executing CREATE SHARDING TABLE RULE,a new sharding algorithm will be created automatically. The algorithm naming rule is tableName_scope_shardingAlgorithmType,such as t_order_database_inline
    • executing CREATE DEFAULT SHARDING STRATEGY,a new sharding algorithm is also created automatically,The algorithm naming rule is default_scope_shardingAlgorithmType,such as default_database_inline

    Sharding Table Reference Rule

    1. ALTER SHARDING TABLE REFERENCE RULE tableReferenceRuleDefinition [, tableReferenceRuleDefinition] ...
    2. DROP SHARDING TABLE REFERENCE RULE ifExists? ruleName [, ruleName] ...
    3. tableReferenceRuleDefinition:
    4. ruleName (tableName [, tableName] ... )
    • A sharding table can only be associated with one sharding table reference rule
    1. CREATE BROADCAST TABLE RULE tableName [, tableName] ...
    2. DROP BROADCAST TABLE RULE tableName [, tableName] ...

    Example

    Sharding Table Rule

    1. DROP SHARDING AUDITOR IF EXISTS sharding_key_required_auditor;
    1. CREATE SHARDING TABLE RULE t_order (
    2. STORAGE_UNITS(ds_0,ds_1),
    3. SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="4")),
    4. KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
    5. AUDIT_STRATEGY(TYPE(NAME="dml_sharding_conditions"),ALLOW_HINT_DISABLE=true)
    6. );
    7. STORAGE_UNITS(ds_0,ds_1,ds_2,ds_3),
    8. SHARDING_COLUMN=order_id,TYPE(NAME="hash_mod",PROPERTIES("sharding-count"="16")),
    9. KEY_GENERATE_STRATEGY(COLUMN=another_id,TYPE(NAME="snowflake")),
    10. AUDIT_STRATEGY(TYPE(NAME="dml_sharding_conditions"),ALLOW_HINT_DISABLE=true)
    11. );
    12. DROP SHARDING TABLE RULE t_order;
    13. DROP SHARDING ALGORITHM t_order_hash_mod;
    1. CREATE SHARDING TABLE REFERENCE RULE ref_0 (t_order,t_order_item), ref_1 (t_1,t_2);
    2. ALTER SHARDING TABLE REFERENCE RULE ref_0 (t_order,t_order_item,t_user);
    3. DROP SHARDING TABLE REFERENCE RULE ref_0, ref_1;

    Broadcast Table Rule

    1. CREATE BROADCAST TABLE RULE t_a,t_b;
    2. DROP BROADCAST TABLE RULE t_a;