Not able to retrieve data from mysql when table is locked

Spread the love

[adsense]MySQL enables client sessions to acquire table locks explicitly for the purpose of cooperating with other sessions for access to tables, or to prevent other sessions from modifying tables during periods when a session requires exclusive access to them.

A session can acquire or release locks only for itself. One session cannot acquire locks for another session or release locks held by another session.


…. Operations


First Line will lock the table and the last one will unlock all tables. Middle statement is little bit tricky.

You need to remember few points.

  • You need to lock all tables either read or write which are present in SQL. Examples like

Select * from Table_1 A, Table_2 B Where A.Ref_id =

You need to lock

  • Table_1 as READ or WRITE
  • Table_2 as READ or WRITE

If you lock only one table then it will not work as expected.

1013total visits,1visits today

This entry was posted in Technology and tagged , , , . Bookmark the permalink.