Mysql Lock

LOCK:

Usage:

LOCK TABLES <tbl_name> <lock_type>

lock_type:

READ lock:
    The session that holds the lock can read the table (but not write it).

WRITE lock:
    The session that holds the lock can read and write the table.

 

Check LOCK:

SHOW OPEN TABLES

Column:

In_use:

The number of table locks or lock requests there are for the table.

Name_locked:

Whether the table name is locked. Name locking is used for operations such as dropping or renaming tables.

 

P.S. Check

"SHOW OPEN TABLES" 是看不到 "FLUSH TABLES WITH READ LOCK;" 的 lock

 

--master-data[=value]

It causes the dump output to include a CHANGE MASTER TO statement
1, takes effect when the dump file is reloaded. (Default)
2, comment

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=107;

* It also turns on --lock-all-tables

 


Select without lock

 

SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;
SELECT * FROM TABLE_NAME ;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ;

DOC

http://dev.mysql.com/doc/refman/5.0/en/table-locking.html

 

 

Creative Commons license icon Creative Commons license icon