LOCK and UNLOCK TABLES

LOCK and UNLOCK TABLES

LOCK and UNLOCK TABLES:
Using LOCK TABLE query we can lock base tables for the current thread. If any of the tables are locked by other threads, it blocks until all locks can be acquired. UNLOCK TABLES releases any locks held by the current thread. All tables that are locked by the current thread are implicitly unlocked when the thread issues another LOCK TABLES, or when the connection to the server is closed.

Syntax:
LOCK TABLE [table name] [type of lock];
UNLOCK TABLE ;

Example:

1) LOCK TABLE salary READ;
SELECT count(*) FROM salary AS sal;
2) UNLOCK TABLE;
SELECT (*) FROM salary AS sal;

Output:
1) Table ’sal’ was not locked with LOCK TABLES
2)750.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.