ERROR 1100 (HY000): Table ' T1 ' is not locked with LOCK TABLES

Source: Internet
Author: User
Session1:


Mysql> Show create table T \g;
1. Row ***************************
Table:t
Create table:create Table ' t ' (
' id ' int (one) DEFAULT NULL,
' Name ' char ' DEFAULT NULL
) Engine=innodb DEFAULT Charset=utf8
1 row in Set (0.00 sec)


ERROR:
No query specified


mysql> lock table T read;
Query OK, 0 rows affected (1 min 3.82 sec)

Mysql> Show open tables from test;
+----------+-------+--------+-------------+
| Database | Table | In_use | name_locked |
+----------+-------+--------+-------------+
| Test |      T |           1 | 0 |
| Test |      T1 |           0 | 0 |
+----------+-------+--------+-------------+
2 rows in Set (0.00 sec)

Mysql> select * from T;
+------+------+
| ID | name |
+------+------+
| 1 | AAAA |
| 2 | BBB |
| 3 | DDD |
| 4 | TTT |
+------+------+
4 rows in Set (0.00 sec)

Mysql> select * from T1;
ERROR 1100 (HY000): Table ' T1 ' is not locked with LOCK TABLES
Mysql> Update T set name= ' a ';
ERROR 1099 (HY000): Table ' t ' is locked with a READ lock and can ' t is updated
mysql> INSERT INTO T1 values (1, ' AA ');
ERROR 1100 (HY000): Table ' T1 ' is not locked with LOCK TABLES
mysql> Delete from T1;
ERROR 1100 (HY000): Table ' T1 ' is not locked with LOCK TABLES


Mysql> insert INTO t values (5, ' e ');
ERROR 1099 (HY000): Table ' t ' is locked with a READ lock and can ' t be updated
mysql> update t set name= ' C '; ERROR 1099 (HY000): Table ' t ' is locked with a READ lock and can ' t is updated
mysql> delete from T;
ERROR 1099 (HY000): Table ' t ' is locked with a READ lock and can ' t is updated



In opening a sesion2:

Mysql> select * from T;
+------+------+
| ID | name |
+------+------+
| 1 | AAAA |
| 2 | BBB |
| 3 | DDD |
| 4 | TTT |
+------+------+
4 rows in Set (0.00 sec)


Mysql> select * from T1;
+------+------+
| ID | name |
+------+------+
| 1 | A |
| 2 | B |
| 3 | D |
| 3 | D |
+------+------+
4 rows in Set (0.00 sec)


mysql> Delete from T1 where id=3;
Query OK, 2 rows affected (0.03 sec)


Mysql> select * from T1;
+------+------+
| ID | name |
+------+------+
| 1 | A |
| 2 | B |
+------+------+


mysql> INSERT INTO T1 values (3, ' d ');
Query OK, 1 row affected (0.03 sec)
2 rows in Set (0.00 sec)


Mysql> INSERT into t values (3, ' d ');
Jammed

Mysql> Delete from T;

Jammed

Update T set name= ' a ';

Jammed
Conclusion: It is usually session1 because a process locks T and wants to access another T1 when the lock is not released, the error 1100 (HY000) is reported: Table ' T1 ' is not locked with LOCK TABLES

in MySQL, if a session uses lock table Tname Read|write to lock a table,

then the same session can only query the locked table, can not update the locked table Insert Delete, do not allow the table is not locked query update insert Delete, the other session on the locked table can only query, can not update, Insert,delete operation

other sessions are still available for SELECT, Update, insert, and delete operations on tables that are not locked





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.