mycat自增主键

自增主键配置:


         从MyCAT 1.3开始,支持自增长主键,依赖于全局序列号机制,建议采用数据库方式的全局序列号,并正确设置步长,以免影响实际性能。

         首先要开启数据库方式的全局序列号,对于需要定义自增长主键的表,建立对应的全局序列号,与table名称同名大写,

         如customer序列名为CUSTOMER,然后再 schema.xml 中对customer表的table元素增加属性autoIncrement值为true.

        <table name=”CUSTOMER”  autoIncrement=”true”>

执行insert into customer (name,company_id,sharding_id) values ('test',2,10000);查看效果,

暂不支持主键为null如:insert into customer (id,name,company_id,sharding_id) values (null,'test',2,10000);

猜你喜欢

转载自sanniangmiao.iteye.com/blog/2249124