When multiple users modify a table, they may face the following problem: the current field id ranges from 1 to 100. If user a and user B want to insert data at the same time, after maxcompute is used to obtain the table's maximum value of 100, data with the id of 101 is inserted. in this way, the table has two data IDs of 101. to solve this problem, you must put the query max and the inserted data in the same statement for execution.
When multiple users modify a table, they may face the following problem: the current field id ranges from 1 to 100. If user a and user B want to insert data at the same time, after maxcompute is used to obtain the table's maximum value of 100, data with the id of 101 is inserted. in this way, the table has two data IDs of 101. to solve this problem, you must put the query max and the inserted data in the same statement for execution.
When multiple users modify tables, they may face the following problems:
There is a field id, from 1 to 100. If user a and B want to insert data at the same time, use max to get the maximum value of 100 in the table, all data with the id of 101 is inserted. in this way, the table has two data IDs of 101.
To solve this problem, you must put the query max and the inserted data in the same statement for execution, in order to avoid problems in the public zone during multithreading.
Sequence objects can be used in oracle to solve this problem.
Create sequence seq;
Multiple Use
Select seq. nextval from dual;
The result is incremental.
Duplicate data is not generated when multiple users are simultaneously used.
For example, insert data to the article table:
Insert into article values (seq. nextval, 'A', 'B ');
Insert into article values (seq. nextval, 'A', 'B ');
Insert into article values (seq. nextval, 'A', 'B ');
Insert into article values (seq. nextval, 'A', 'B ');
..............
The seq. nextval inserted in the id field is incremental and repeated.