Select * from xxx where id in (xx,xx,xx) for update
mysql> select * from t3 where id in (8,9) for update; ---- -------- ------ --------------------- | id | course | name | ctime | ---- -------- ------ --------------------- | 8 | WA | f | 2016-03-02 11:36:30 | | 9 | JX | f | 2016-03-01 11:36:30 | ---- -------- ------ --------------------- rows in set (0.04 sec)
select * from t3 where id in (10,8,5) for update;
mysql> select * from t3 where id=5 for update;
mysql> select * from t3 where id=10 for update; ---- -------- ------ --------------------- | id | course | name | ctime | ---- -------- ------ --------------------- | 10 | JB | g | 2016-03-10 11:45:05 | ---- -------- ------ --------------------- row in set (0.00 sec)
select * from t3 where id=22 for update; Empty set (0.00 sec)
select * from t3 where id=23 for update; Empty set (0.00 sec)
insert into t3 values(22,'ac','a',now());
insert into t3 values(23,'bc','b',now());
insert into t3(xx,xx) on duplicate key update `xx`='XX';
mysql> select * from t3 where id=9 for update; ---- -------- ------ --------------------- | id | course | name | ctime | ---- -------- ------ --------------------- | 9 | JX | f | 2016-03-01 11:36:30 | ---- -------- ------ --------------------- row in set (0.00 sec)
mysql> select * from t3 where id<20 for update;
mysql> insert into t3 values(7,'ae','a',now());
CREATE TABLE dltask ( id bigint unsigned NOT NULL AUTO_INCREMENT COMMENT ‘auto id’, a varchar(30) NOT NULL COMMENT ‘uniq.a’, b varchar(30) NOT NULL COMMENT ‘uniq.b’, c varchar(30) NOT NULL COMMENT ‘uniq.c’, x varchar(30) NOT NULL COMMENT ‘data’, PRIMARY KEY (id), UNIQUE KEY uniq_a_b_c (a, b, c) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=’deadlock test’;
delete from dltask where a=? and b=? and c=?;
delete from dltask where a=’a’ and b=’b’ and c=’c’;
END 十期推荐 【231期】面试官:Java中 serialVersionUID 的作用是什么? 【232期】面试官:Spring的 IOC 容器比New对象究竟好在哪? 【233期】面试官:什么是耦合?解耦合的方法有哪几种? 【234期】30个 Java 集合面试必备的问题和答案 【235期】面试官:Redis的数据是存在内存里吗?谈谈Redis各种数据类型的使用场景? 【236期】面试官:线程池中多余的线程是如何回收的? 【237期】面试官:如何发现 Redis 热点 Key ,解决方案有哪些? 【238期】面试官:Redis新版本开始引入多线程,谈谈你的看法? 【239期】面试官:如何使用Redis实现电商系统的库存扣减? 【240期】面试官:你了解JVM的内存溢出吗? ? ~