表组 #
语法 | 描述 | 类型 |
---|---|---|
CREATE SHARDING TABLE REFERENCE RULE | 创建分片表关联 | RDL |
ALTER SHARDING TABLE REFERENCE RULE | 修改分片表关联 | RDL |
DROP SHARDING TABLE REFERENCE RULE | 删除表关联 | RDL |
SHOW SHARDING TABLE REFERENCE RULE | 查看表关联 | RQL |
1. 创建分片表组 #
createShardingTableReferenceRule
: CREATE SHARDING TABLE REFERENCE RULE ifNotExists? tableReferenceRuleDefinition (, tableReferenceRuleDefinition)*
;
tableReferenceRuleDefinition
: ruleName ( tableName (, tableName)* )
;
ifNotExists
: IF NOT EXISTS
;
示例
CREATE SHARDING TABLE REFERENCE RULE reference_0 (t_order,t_order_item), reference_1 (t_1,t_2);
2. 修改分片表组 #
alterShardingTableReferenceRule
: ALTER SHARDING TABLE REFERENCE RULE ifNotExists? tableReferenceRuleDefinition (, tableReferenceRuleDefinition)*
;
tableReferenceRuleDefinition
: ruleName ( tableName (, tableName)* )
;
ifNotExists
: IF NOT EXISTS
;
示例
ALTER SHARDING TABLE REFERENCE RULE reference_0 (t_order,t_order_item), reference_1 (t_1,t_2);
3. 删除分片表组 #
dropShardingTableReferenceRule
: DROP SHARDING TABLE REFERENCE RULE ifExists? ruleName (, ruleName)*
;
ifExists
: IF EXISTS
;
示例
DROP SHARDING TABLE REFERENCE RULE reference_0;
4. 查看表组 #
showShardingTableReferenceRules
: SHOW SHARDING TABLE REFERENCE (RULE ruleName | RULES) (FROM databaseName)?
;
示例
mysql> SHOW SHARDING TABLE REFERENCE RULE reference_0;
+-------------+--------------------------+
| name | sharding_table_reference |
+-------------+--------------------------+
| reference_0 | t_order,t_order_item |
+-------------+--------------------------+
1 rows in set (0.00 sec)
输出说明
列 | 说明 |
---|---|
name | 表组名称 |
sharding_table_reference | 表组成员 |