[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.
LOCK TABLES t1 WRITE, t2 READ;
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 = B.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.
75total visits,8visits today