In MySQL, just like there is locking involved with SELECT combined with INSERT or CREATE, does the same hold true for SELECT column INTO @variable statement?
Asked
Active
Viewed 240 times
1 Answers
0
Assuming InnoDB and no explicit locking (FOR UPDATE
, etc.) - no locks are involved.
It's just a normal select, except that the result goes in to some variables.
The locking in the other cases is because of the INSERT/UPDATE, not the select itself (and it doesn't lock the tables in the select).
CREATE TABLE ... SELECT ...
doesn't lock anything afaik.

Vatev
- 7,493
- 1
- 32
- 39
-
From the fine manual :) "CREATE TABLE ... SELECT ... performs the SELECT with shared next-key locks or as a consistent read, as for INSERT ... SELECT." https://dev.mysql.com/doc/refman/5.7/en/innodb-locks-set.html – Deb Aug 08 '18 at 12:44
-
Well... yes, apparently it does, for REPEATABLE READ and SERIALIZABLE. No locks for READ COMMITTED though :) – Vatev Aug 08 '18 at 12:53