Thursday, 15 September 2011

MySQL Multiple table locks -



MySQL Multiple table locks -

i have little curiosity mysql table locks.

say want lock 2 tables. execute command:

lock tables table1 write, table2 write

and checked if tables have indeed been locked executing:

show open tables in mydatabase in_use > 0

i have noticed tho if run 2 lock commands sequentitally example:

lock tables table1 write lock tables table2 write

and check tables locked using same command table2 marked locked. why so?

thanks

lock tables not transaction-safe , implicitly commits active transaction before attempting lock tables.

so, in first case, have 1 transaction hold 2 tables locked, in sec one, because lock tables table1 write had been commited

mysql

No comments:

Post a Comment