From java using MySql database, how can check whether a row or range of rows is locked in a table ?
Asked
Active
Viewed 2,417 times
4
-
You mean a check if table is locked? – drgPP Sep 11 '15 at 07:18
2 Answers
2
If you want to check if a table is locked then you can try like this:
SHOW OPEN TABLES
but you cannot check if a range of rows is locked.
You can also make it specific for a particular table like this:
SHOW OPEN TABLES WHERE `Table` LIKE '[YOURTABLENAME]'
AND `Database` LIKE '[YOURDATABASENAME]' AND In_use > 0;
As per my opinion when a table is locked then the rows are locked automatically.

Rahul Tripathi
- 168,305
- 31
- 280
- 331
-1
MySQL uses only table-level locking. If you want row level locking capabilities, switch to InnoDB(A suggestion not a must).

diyoda_
- 5,274
- 8
- 57
- 89
-
1`InnoDB` is a database engine used by `MySQL`, so your answer isn't exactly correct. – Kayaman Sep 11 '15 at 07:35
-
@Kayaman You are correct, I should add somewhere to the answer about the MyISAM Storage Engine. But obviously the user seems to be using InnoDB engine. – diyoda_ Sep 11 '15 at 07:39