Mycat对表t_rc_rule_monitor做分表操作
在mysql上执行(没有t_rc_rule_monitor)
DROP TABLE IF EXISTS t_rc_rule_monitor;
CREATE TABLE t_rc_rule_monitor(
id int(20) NULL auto_increment ,
system_id varchar(32) NOT NULL,
group_no varchar(32) NOT NULL ,
rule_code varchar(30) NOT NULL ,
merchant_id varchar(20) NOT NULL,
payclass_id int(20) NOT NULL,
is_risk char(1) NOT NULL ,
cost_time int(5) NULL ,
create_date LONG NULL ,
primary key(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
配置:
vi server.xml
<property name="sequnceHandlerType">0</property>
vi schema.xml
<table name="T_RC_RULE_MONITOR" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2" rule="mod-long"/>
vi sequence_conf.properties
GLOBAL.HISIDS=
GLOBAL.MINID=10001
GLOBAL.MAXID=200000000
GLOBAL.CURID=10000
T_RC_RULE_MONITOR.HISIDS=
T_RC_RULE_MONITOR.MINID=10001
T_RC_RULE_MONITOR.MAXID=200000000
T_RC_RULE_MONITOR.CURID=10000
vi rule.xml
<function name="mod-long" class="io.mycat.route.function.PartitionByMod">
<!-- how many data nodes -->
<property name="count">2</property>
</function>
向该表插入数据不用写id字段,会自行插入增长id
例子:
insert into tt(id,name_) values(next value for MYCATSEQ_GLOBAL,1);
insert into tt(id,name_) values(next value for MYCATSEQ_TT,2);
insert into tt(name_) values(5);