- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL Error ERROR 1099 (HY000): Table was locked with a READ lock and can't be updated
To get rid of LOCK TABLES query, you need to use UNLOCK TABLES.
Let us create a table −
mysql> create table demo6 −> ( −> country_name varchar(100 −> ) −> ); Query OK, 0 rows affected (1.51 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo6 values('US'); Query OK, 1 row affected (0.11 sec) mysql> insert into demo6 values('UK'); Query OK, 1 row affected (0.08 sec) mysql> insert into demo6 values('AUS'); Query OK, 1 row affected (0.11 sec)
Display records from the table using select statement −
mysql> select *from demo6;
This will produce the following output −
+--------------+ | country_name | +--------------+ | US | | UK | | AUS | +--------------+ 3 rows in set (0.00 sec)
Here, I have a lock on the above table only for read operator. Following is the query −
mysql> lock tables demo6 read; Query OK, 0 rows affected (0.00 sec)
Following is the error when you try to insert on the above table −
mysql> insert into demo6 values('IND'); ERROR 1099 (HY000): Table 'demo6' was locked with a READ lock and can't be updated
If you use UNLOCK TABLES, then you can insert records in the same table −
mysql> UNLOCK TABLES; Query OK, 0 rows affected (0.00 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo6 values('IND'); Query OK, 1 row affected (0.09 sec)
Display records from the table using select statement −
mysql> select *from demo6;
This will produce the following output −
+--------------+ | country_name | +--------------+ | US | | UK | | AUS | | IND | +--------------+ 4 rows in set (0.00 sec)
- Related Articles
- Fix ERROR 1093 (HY000): You can't specify target table for update in FROM clause while deleting the lowest value from a MySQL column?
- Solve ERROR 1396 (HY000): Operation DROP USER failed for 'user'@'localhost' in MySql?
- ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'?
- How can I tell when a MySQL table was last updated?
- Fix: ERROR 1396 (HY000): Operation CREATE USER failed in MySQL?
- MySQL query error with a table named “order”?
- Fix for MySQL ERROR 1406: Data too long for column” but it shouldn't be?
- Linux – How to resolve the error "can't connect to Docker daemon"
- Resolve the MySQL error 'TYPE=MyISAM'?
- How can we tackle MySQL error ‘ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement’ while importing or exporting the data?
- Why JavaScript 'var null' throw an error but 'var undefined' doesn't?
- Fix MySQL ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
- How to deal with error 'height' must be a vector or a matrix while creating barplot?
- Fix Error in MySQL syntax while creating a table column with name “index”?
- Fix MySQL Error #1064 - You have an error in your SQL syntax… near 'TYPE=MyISAM?

Advertisements