innodb-deadlock.result

来自「这是linux下运行的mysql软件包,可用于linux 下安装 php + m」· RESULT 代码 · 共 97 行

RESULT
97
字号
drop table if exists t1,t2;create table t1 (id integer, x integer) engine=INNODB;insert into t1 values(0, 0);set autocommit=0;SELECT * from t1 where id = 0 FOR UPDATE;id	x0	0set autocommit=0;update t1 set x=2 where id = 0;update t1 set x=1 where id = 0;select * from t1;id	x0	1commit;commit;select * from t1;id	x0	2commit;drop table t1;create table t1 (id integer, x integer) engine=INNODB;create table t2 (b integer, a integer) engine=INNODB;insert into t1 values(0, 0), (300, 300);insert into t2 values(0, 10), (1, 20), (2, 30);commit;set autocommit=0;select * from t2;b	a0	101	202	30update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);select * from t2;b	a0	1001	202	30select * from t1;id	x0	0300	300set autocommit=0;update t1 set x=2 where id = 0;update t1 set x=1 where id = 0;select * from t1;id	x0	1300	300commit;commit;select * from t1;id	x0	2300	300commit;drop table t1, t2;create table t1 (id integer, x integer) engine=INNODB;create table t2 (b integer, a integer) engine=INNODB;insert into t1 values(0, 0), (300, 300);insert into t2 values(0, 0), (1, 20), (2, 30);commit;select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;a	b0	020	130	2300	300select * from t2;b	a0	01	202	30select * from t1;id	x0	0300	300update t2 set a=2 where b = 0;select * from t2;b	a0	21	202	30update t1 set x=2 where id = 0;update t1 set x=1 where id = 0;select * from t1;id	x0	1300	300commit;commit;select * from t1;id	x0	2300	300commit;drop table t1, t2;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?