@lyxiang
2019-07-08T11:42:56.000000Z
字数 1150
阅读 642
未分类
表锁 | 行锁 | 页锁 |
---|---|---|
MyISAM | 支持 | 不支持 |
BDB | 支持 | 支持 |
InnoDB | 支持 | 支持 |
//对数据对象A加上S锁
start transaction;
select * from yitiao_user_coupon where id = 90 LOCK IN SHARE MODE; //commit之后,就会释放S锁
//在看一个事务,去更新数据对象A
start transaction;
update yitiao_user_coupon set coupon_id = 9 where id = 90; //等待锁
//查看锁sql
select * from information_schema.processlist where COMMAND = 'Query' and db = 'xxx';
//杀死锁
kill id
//对数据对象A加上S锁
start transaction;
select * from yitiao_user_coupon where id = 90 for update; //commit之后,就会释放S锁
//在看一个事务,去更新数据对象A
start transaction;
select * from yitiao_user_coupon where id = 90 LOCK IN SHARE MODE; //等待锁
//查看锁sql
select * from information_schema.processlist where COMMAND = 'Query' and db = 'xxx';
//杀死锁
kill id