CREATE SHARDING BINDING TABLE RULE
语法用于为具有分片规则的表(分片表)添加绑定关系并创建绑定规则
CreateBindingTableRule ::=
'CREATE' 'SHARDING' 'BINDING' 'TABLE' 'RULES' bindingRelationshipDefinition (',' bindingRelationshipDefinition )*
bindingRelationshipDefinition ::=
'(' tableName (',' tableName)* ')'
tableName ::=
identifier
ds_${0..1}.t_order_${0..1}
与 ds_${0..1}.t_order_item_${0..1}
;t_order_${order_id % 2}
与 t_order_item_${order_item_id % 2}
;CREATE SHARDING BINDING TABLE RULE
。
当绑定规则已经存在但还需要添加绑定关系时,需要使用 ALTER SHARDING BINDING TABLE RULE
来修改绑定规则。-- 创建绑定关系之前需要先创建分片表 t_order,t_order_item
CREATE SHARDING BINDING TABLE RULES (t_order,t_order_item);
-- 创建绑定关系之前需要先创建分片表 t_order,t_order_item,t_product,t_product_item
CREATE SHARDING BINDING TABLE RULES (t_order,t_order_item),(t_product,t_product_item);
CREATE
、SHARDING
、BINDING
、TABLE
、RULES