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.