1. Local file Mode
Sequncehandlertype = 0
/Root/data/Program/MyCat/CONF/server. xml <property name = "sequncehandlertype"> 0 </property>
Configure sequence_conf.properties
/Root/data/Program/MyCat/CONF/sequence_conf.properties
Users. hisids =
Users. minid = 1001.
Users. maxid = 100000000
Users. curid = 1000.
Note: The users here is the upper case of the table name configured in server. xml.
<schema name="db_user" checkSQLschema="false" sqlMaxLimit="100"> <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/> <table name="users" dataNode="db_user_dataNode$1-2" rule="mod-userID-long" primaryKey="userID"> <childTable name="user_address" joinKey="userID" parentKey="userID" primaryKey="addressID"/> </table></schema>
Use next value for mycatseq_xxx
Insert into users (userid, phonenum) values (next value for mycatseq_users, '123 ');
Effect
2. Database Methods
Sequncehandlertype = 1
/Root/data/Program/MyCat/CONF/server. xml <property name = "sequncehandlertype"> 1 </property>
Configure/root/data/Program/MyCat/CONF/sequence_db_conf.properties
Users = db_user_datanode2
Add the mycat_sequence table to the specified schema.
<Table name = "mycat_sequence" datanode = "db_user_datanode2"/>
<schema name="db_user" checkSQLschema="false" sqlMaxLimit="100"> <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/> <table name="users" dataNode="db_user_dataNode$1-2" rule="mod-userID-long" primaryKey="userID"> <childTable name="user_address" joinKey="userID" parentKey="userID" primaryKey="addressID"/> </table> <table name = "mycat_sequence" dataNode ="db_user_dataNode2" /> </schema>
Use next value for mycatseq_xxx or specify autoincrement
Insert into users (userid, phonenum) values (next value for mycatseq_users, '123 ');
Another method: Specify autoincrement = "true"
<schema name="db_user" checkSQLschema="false" sqlMaxLimit="100"> <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/> <table name="users" dataNode="db_user_dataNode$1-2" rule="mod-userID-long" primaryKey="userID" autoIncrement="true"> <childTable name="user_address" joinKey="userID" parentKey="userID" primaryKey="addressID"/> </table> <table name = "mycat_sequence" dataNode ="db_user_dataNode2" /> </schema>
Insert into users (phonenum) values ("8888 ");
3. Local Timestamp
Id = 64-bit binary (42 (millisecond) + 5 (machine ID) + 5 (Business Code) + 12 (repeated accumulation)
Sequncehandlertype = 2
/Root/data/Program/MyCat/CONF/server. xml <property name = "sequncehandlertype"> 2 </property>
Configure sequence_time_conf.properties
Default Configuration
Specify autoincrement
Only autoincrement can be specified.
<schema name="db_user" checkSQLschema="false" sqlMaxLimit="100"> <table name="data_dictionary" type="global" dataNode="db_user_dataNode1,db_user_dataNode2" primaryKey="dataDictionaryID"/> <table name="users" dataNode="db_user_dataNode$1-2" rule="mod-userID-long" primaryKey="userID" autoIncrement="true"> <childTable name="user_address" joinKey="userID" parentKey="userID" primaryKey="addressID"/> </table> <table name = "mycat_sequence" dataNode ="db_user_dataNode2" /> </schema>
MyCat global Sequence