会员登录 | 会员注册 | 意见建议 | 网站地图

站长资源综合门户

当前位置:首页 > 站长学院 > 数据库 > MySQL InnoDB之事务与锁详解

MySQL InnoDB之事务与锁详解

时间:2012-04-01 18:50:08   作者:   来源:   点击:
:SET GLOBAL tx_isolation=’REPEATABLE-READ’ID事务1事务1输出事务2事务2输出1START TRANSACTION;   2select max(ID) FROM account;124999  3  START TRANSACTION; 4UPDATE account set gmt_create=date_add(gmt_create,interval +1 day) WHERE ID >=124999;   5  insert into account(VACCOUNT_ID,gmt_create) values(‘eugene’,now());STATE:update6  事务2超时 7  START TRANSACTION; 8  SELECT * FROM account WHERE ID =124998;2007-10-20 13:479  UPDATE account set gmt_create=date_add(gmt_create,interval +1 day) WHERE ID =124998;执行成功10  SELECT * FROM account WHERE ID =124998;2007-10-21 13:4711COMMIT;   12  COMMIT;      1START TRANSACTION;   2UPDATE account set gmt_create=date_add(gmt_create,interval -1 day) WHERE gmt_create >’2009-07-01′;   3  START TRANSACTION; 4  SELECT * FROM account WHERE gmt_create>’2009-07-10′ LIMIT 1;2009-10-2 13:475SELECT * FROM account WHERE gmt_create>’2009-07-10′ LIMIT 1;2009-10-1 13:47 STATE:update6  insert into account(VACCOUNT_ID,gmt_create) values(‘gmt_create_test’,now()); 7  事务2超时 8COMMIT;   9  SELECT * FROM account WHERE gmt_create>’2009-07-10′ LIMIT 1;2009-10-1 13:47无索引条件更新事务1START TRANSACTION;    UPDATE account set gmt_create=date_add(gmt_create,interval -1 day) WHERE gmt_create >’2009-07-01′ AND gmt_create <’2009-07-10′;      START TRANSACTION;    insert into account(VACCOUNT_ID,gmt_create) values(‘gmt_create_interval’,now());    事务2超时  COMMIT;   

 

分享到:

网友评论

推荐数据库

热门数据库