MyCat global Sequence

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.