mysl lock table read
<pre name="code" class="html">Session 1:
mysql> use zjzc;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> select * from test;
+------+------+
| id | name |
+------+------+
| NULL | a |
| 2 | b |
| 3 | c |
| 1 | a |
+------+------+
4 rows in set (0.00 sec) mysql> lock table test read;
Query OK, 0 rows affected (0.00 sec) mysql> select * from test;
+------+------+
| id | name |
+------+------+
| NULL | a |
| 2 | b |
| 3 | c |
| 1 | a |
+------+------+
4 rows in set (0.00 sec) mysql> insert into test values(4,'a');
ERROR 1099 (HY000): Table 'test' was locked with a READ lock and can't be updated Session 2: Database changed
mysql> select * from test;
+------+------+
| id | name |
+------+------+
| NULL | a |
| 2 | b |
| 3 | c |
| 1 | a |
+------+------+
4 rows in set (0.00 sec) mysql> insert into test values(4,'a'); 由于session 1加了只读锁,session2无法插入 session 2也可以加只读锁;
mysql> lock table test read;
Query OK, 0 rows affected (0.00 sec) mysql> insert into test values(4,'a');
ERROR 1099 (HY000): Table 'test' was locked with a READ lock and can't be updated 一个session只能为自己获取锁和释放锁,不能为其他session获取锁,也不能释放由其他session保持的锁。 UNLOCK TABLES还还以用来释放FLUSH TABLES WITH READ LOCKS获取的全局锁,该锁锁定所有库的所有表。 /*************
[root@wx03 sbin]# perl a2.pl
$XDATE is 20160823132742
DBD::mysql::db do failed: Table 't1' was locked with a READ lock and can't be updated at a2.pl line 12.
[root@wx03 sbin]# cat a2.pl
use DBI;
use POSIX;
$db_name='scan';
$ip='127.0.0.1';
$user="root";
$passwd="R00t,uHagt.0511";
$dbh = DBI->connect("dbi:mysql:database=$db_name;host=$ip;port=3306",$user,$passwd
) or die "can't connect to database ". DBI-errstr;
my $XDATE = strftime("%Y%m%d%H%M%S",localtime());
print "\$XDATE is $XDATE\n";
$dbh->do("lock table t1 read") or die $dbh->errstr ;
$dbh->do("insert into t1 values(90)");
$dbh->disconnect; [root@wx03 sbin]# perl a2.pl
$XDATE is 20160823132747
DBD::mysql::db do failed: Table 't1' was locked with a READ lock and can't be updated at a2.pl line 12.
mysl lock table read的更多相关文章
- MYSQL 遭遇 THE TOTAL NUMBER OF LOCKS EXCEEDS THE LOCK TABLE SIZE
今天进行MySql 一个表数据的清理,经过漫长等待后出现 The total number of locks exceeds the lock table size 提示.以为是table_cache ...
- mysql:The total number of locks exceeds the lock table size
使用mysql InnoDB存储引擎进行大量数据的更新,删除的时候容易引发”The total number of locks exceeds the lock table size”问题,解决方法之 ...
- MySQL配置文件路径及‘The total number of locks exceeds the lock table size’问题
在删除mysql中的数据时,遇到报错: ERROR 1206 (HY000): The total number of locks exceeds the lock table size 查了查,发现 ...
- mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
1. 问题背景 InnoDB是新版MySQL(v5.5及以后)默认的存储引擎,之前版本的默认引擎为MyISAM,因此,低于5.5版本的mysql配置文件.my.cnf中,关于InnoD ...
- lock table
1.在执行lock table语句后,则在执行unlock tables之前,当前会话只能操作当前被锁定的表(包括表别名)2.read锁,其它会话只有读取权限,没有写入权限3.write锁,其它会话只 ...
- Mysql_解决The total number of locks exceeds the lock table size错误
在操作mysql数据库表时出现以下错误. 网上google搜索相关问题,发现一位外国牛人这么解释: If you're running an operation on a large number o ...
- MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题
MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题 查看MySQL版本:mysql>show ...
- mysql 数据库缓存调优之解决The total number of locks exceeds the lock table size错误
环境: mysql5.6.2 主从同步(备注:需操作主库和从库) 一.InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_poo ...
- 【MySQL笔记】mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法
step1:查看 1.1 Mysql命令行里输入"show engines:"查看innoddb数据引擎状态, 1.2 show variables "%_buffer% ...
随机推荐
- Canvas基础学习(一)——实现简单时钟显示
HTML5最受欢迎的功能就是<canvas>元素.这个元素负责在页面中设定一个区域,然后就可以通过JavaScript动态地在这个区域中绘制图形.关于<canvas>元素的一些 ...
- YII学习,初体验 ,对YII的一些理解.
先说点没用的: 不会选择,选择后不坚持,不断的选择.这是人生中的一个死循环,前两一直迷茫.觉得自己前进方向很不明朗.想去学的东西有很多.想学好YII,想学PYTHON 想学学hadoop什么的,又想研 ...
- js 异步流程控制之 avQ(avril.queue)
废话前言 写了多年的js,遇到过最蛋疼的事情莫过于callback hell, 相信大家也感同身受. 业界许多大大也为此提出了很多不错的解决方案,我所了解的主要有: 朴灵 event proxy, 简 ...
- VS调试时监视上一个错误代码和错误的文本描述
以前我都是用GetLastError()然后在MSDN里面查错误原因的.现在才知道有很简便的方法: 在Watch窗口选择一行,然后输入$err,hr
- 【LeetCode练习题】Permutation Sequence
Permutation Sequence The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and ...
- C Statements
1,while((ch = getchar()) != EOF){ putchar(ch);}2,while((ch=getchar()) != EOF){ if(ch < '0' ...
- Python学习笔记10-Python MysqlHelper ,MySql 辅助类
自己写了一个MySql辅助类,有需要的拿走: #--encoding:utf-8-- # import MySQLdb class MySQLHelper: myVersion=0.1 def __i ...
- .net面试问答(大汇总)
用.net做B/S结构的系统,您是用几层结构来开发,每一层之间的关系以及为什么要这样分层? 答:从下至上分别为:数据访问层.业务逻辑层(又或成为领域层).表示层 数据访问层:有时候也称为是持久层,其功 ...
- 网页前台的iframe控制内部刷新子页
<body> <!--Header--> <uc1:top runat="server" ID="top" /> <! ...
- CodeForces 132C Logo Turtle (记忆化搜索)
Description A lot of people associate Logo programming language with turtle graphics. In this case t ...