Home > database >  Many users input data at the same time, single number how to solve
Many users input data at the same time, single number how to solve

Time:09-27

The first user to add data access to the largest number is S2019122601, on the basis of the + 1, get S2019122602, not to save the data, there were also added to the second user data access number is S2019122602, how to solve the problem of the single number? Does anyone know how to solve, thank you!

CodePudding user response:

When users click save in the database to obtain the biggest single number,

CodePudding user response:

The number generated and take them to the insert statement and verify whether there is

CodePudding user response:

Multi-user is parallel, serial, but you can only have to line up,

According to this to:
https://blog.csdn.net/yenange/article/details/78903480

Store insert into serial execution can,

CodePudding user response:

Is there a way can be obtained in the second user number is automatically get to S2019122603

CodePudding user response:

Don't use maximum record in a table, with sequene directly (if your version does not support, then directly in a table)
If you must use maximum record in a table, then the requirements of the transaction isolation level to achieve SERIALIZABLE, this will seriously affect the performance, and easy to deadlock

CodePudding user response:

reference 4 floor weixin_42553422 response:
is there any way to at the time of the second user access number is automatically get S2019122603?


 
Insert Into table (number) values (Max (number) + 1)

CodePudding user response:

refer to 6th floor one tree forest _ response:
Quote: refer to 4th floor weixin_42553422 response:

Is there a way can be obtained in the second user number is automatically get to S2019122603?


 
Insert Into table (number) values (Max (number) + 1)


Mainly, before the user is not saved, data is not the single number, he new add another user point when will repeat with him

CodePudding user response:

refer to 7th floor weixin_42553422 response:
Quote: refer to the sixth floor one tree forest _ response:

Quote: refer to 4th floor weixin_42553422 response:

Is there a way can be obtained in the second user number is automatically get to S2019122603?


 
Insert Into table (number) values (Max (number) + 1)


Mainly, before the user is not saved, data is not the single number, he new add another user points will and he repeated


You use this statement does not affect the other user actions,

CodePudding user response:

To a simple ideas

Create a table, only two fields, one on the field, a date/time field

Generated code into a function or a stored procedure

In the inserted into the table just now, and then get the insert id, scope_identity () and insert the time, according to the calculated number, and then return
  • Related