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% ...
随机推荐
- Yii系列总结:yii 标签用法
yii 常用标签:label标签.文本标签.error标签.textarea标签.hidden标签.password标签.url标签.radio标签.file标签.button标签.checkBox标 ...
- python成长之路第三篇(1)_初识函数
目录: 函数 为什么要使用函数 什么是函数 函数的返回值 文档化函数 函数传参数 文件操作(二) 1.文件操作的步骤 2.文件的内置方法 函数: 一.为什么要使用函数 在日常写代码中,我们会发现有很多 ...
- jquery multiselect控件
http://www.erichynds.com/blog/jquery-ui-multiselect-widget
- SQL Server 索引整理与堆重组。
重新组织索引: alter index idx_OrderID on dbo.OrderDetail reorganize | reorganize;---可以rebuild 也可 ...
- python学习day9
目录 一.队列 二.生产者消费者模型 三.协程 四.select\poll\epoll 五.paramiko 六.mysql API调用 一.队列(queue) 队列分以下三种: class queu ...
- Java Script 中 ==(Equal) 和 === (Identity Equal) 的区别和比较算法逻辑
判断两个变量是否相等在任何编程语言中都是非常重要的功能. JavaScript 提供了 == 和 === 两种判断两个变量是否相等的运算符,但我们开始学习的时候 JavaScript 的时候,就被一遍 ...
- bzoj2014 [Usaco2010 Feb]Chocolate Buying
Description 贝西和其他奶牛们都喜欢巧克力,所以约翰准备买一些送给她们.奶牛巧克力专卖店里 有N种巧克力,每种巧克力的数量都是无限多的.每头奶牛只喜欢一种巧克力,调查显示, 有Ci头 ...
- Centos下需安装Pytnon,Pytharm
1.在www.python.org/PIPY/下载python3.4.2.tar.gz 2.在安装之前最好先安装相关的开发工具 # yum groupinstall develtools # yum ...
- 格而知之2:UIView的autoresizingMask属性探究
UIView的autoresizingMask属性,是用在当一个UIView实例的父控件的尺寸发生变化时,来自动调整UIView实例在父控件中的位置与尺寸的.autoresizingMask属性是一个 ...
- C#中的反射原理及应用(转)
反射的概述 反射的定义:审查元数据并收集关于它的类型信息的能力.元数据(编译以后的最基本数据单元)就是一大堆的表,当编译程序集或者模块时,编译器会创建一个类定义表,一个字段定义表,和一个方法定义表等, ...