关于mysql的事务测试

事务:

 

CREATE TABLE `student` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
`score` int(255) DEFAULT NULL,
PRIMARY KEY (`id`)
)

//修改事务隔离级别

set global TRANSACTION ISOLATION LEVEL read uncommitted;

set session TRANSACTION ISOLATION LEVEL read uncommitted;

//查看事务隔离级别

select @@global.tx_isolation;
select @@session.tx_isolation;

//测试查询1

begin;
select * from student where id = 1;
select sleep(10);
select * from student where id = 1;
commit;

select * from student where id = 1;

//测试查询2

begin;
update student set score = 23 where id =1;
select sleep(10);
rollback;

 

posted @ 2020-12-22 18:58  yslj  阅读(12)  评论(0)    收藏  举报