MySQL Identifier Sequence

Is this the correct way to generate id in MySQL?

INSERT IN PHOTO (PictureId, First_pick, name, description, File_Name, Is_Vertical) VALUES
((SELECT max (pictureid) +1 FROM Picture), 0,?,?,?,?)

I mean, if this ensures that the PictureId will be unique when this request is launched by many threads?

I can not change the structure of the table. Should I use any specific locks, index level or transaction isolation level?

Regards, Michal

+3
source share
3 answers

AUTO_INCREMENT, :

, mySQL . ?

+3

- , , , .

+2

AUTO_INCREMENT, .

0

Source: https://habr.com/ru/post/1735896/


All Articles