I use the following syntax to insert new records (I don't want duplicate keys):
insert into tbl(key) values select max(key)+1 from tbl
Someone says that he will have a concurrency problem.
Is it correct?
SELECT -> LOCK table -> INSERT
or
LOCK table -> SELECT -> INSERT
Which of the above is correct?
Billy source
share