How to assign a unique player ID in a region

Source: Internet
Author: User


The method for allocating the unique player ID in the region. In Mysql, in addition to using the auto_increment field as the auto-incrementing serial number, there is another way to provide
The unique sequence number. One table can satisfy the requirements of Multiple sequences. Www.2cto.com is roughly as follows: 1. Create table SeqTab (iSeqNo int not null default 0, iSeqType int not null default 0); 2. Insert into SeqTab values (); // 0 indicates the initial SeqNo value. 13 indicates the SeqType.
Multiple applications provide Seq sequence Service 3. Regardless of the multi-process or single-process access to the SeqTab table, use the following method to obtain the serial number 1st-> update SeqTab set iSeqNo = last_insert_id (iSeqNo + 1) where iSeqType = 13; 2nd-> select last_insert_id (); 4. When multiple processes simultaneously access SeqTab and perform update SeqTab set iSeqNo = last_insert_id (iSeqNo + 1,
The database ensures the integrity of the update transaction and last_insert_id () is related to the current mysql connection. Therefore, when multiple processes are used simultaneously, there will be no conflict.

Related Article

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.