Locking & Unlocking Tables in MySql

I am using the following code:

 UPDATE matrix SET dollarsGained = dollarsGained - 10;

1) How doI check that the table is actually locked?
2) How do I just unlock the table 'matix' without unlocking all of them?
3) How do I check that the table is actually unlocked?

Server info:
MySQL 5.0.45-community-nt via TCP/IP
MySQL Client Version 5.1.11
MYISAM tables
Who is Participating?
hernst42Connect With a Mentor Commented:
1 and 3)
Instead of using row-level locks, you can employ application-level locks, such as those provided by GET_LOCK() and RELEASE_LOCK() in MySQL. These are advisory locks, so they work only in well-behaved applications. See Section 11.10.4, Miscellaneous Functions. -> next link

mysql> SELECT GET_LOCK('lock1',10);
        -> 1
mysql> SELECT IS_FREE_LOCK('lock2');
        -> 1
mysql> SELECT GET_LOCK('lock2',10);
        -> 1
mysql> SELECT RELEASE_LOCK('lock2');
        -> 1
mysql> SELECT RELEASE_LOCK('lock1');
        -> NULL

2) not possible to unlock only one table, as this would lead to fast deadlocks in the database. Locks can only be gotten additiv. Allowing to unlock single tables would, as already mentioned, lead to deadlocks very fast.
See http://dev.mysql.com/doc/refman/5.0/en/internal-locking.html there all your questions are answerd
jmokrauerAuthor Commented:
I cannot seem to find the answers you refer to in that link.  Would you cut and paste the actual text you are referring to that answer each of the three questions?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.