显示事务-1

事务
一致性
隔离型
持久性
事务的创建
隐试事务:事务没有明显的开始和结束
比如 insert,upfte,delete语句
delete from 表 where id=11;
显示事务
具有明显的开始和结束的标记
set autocommit=0;
只针对当前的事务有效
前提:必须贤者之自动提交功能为禁用
步骤一:开启事务
set autocomit=0;
strat transaction ;可选的
步骤二:编写事务的sqlyuju(select insert update delete)
语句1;
语句2;
步骤3:结束事务
commit:提交事务
rollback:回滚
演示事务的步骤:
set autocommit=0;
start transction;
编写一组事务的语句
uodate account set balance =500 where username ='张无忌';
u date account set balance set balanse=1500 where uesernmae='张';
结束事务;mit;
rollback;
set session

事务隔离级别: 脏读 幻读 不可重复读
read uncommited: 对 对 对
read committed: x x 对
repeatable read: x x 对
serializable: x x x
mysal: 默认第3个 级别 repeatable read
oracae 中默认第3个隔离界别 read committed
查看隔级别
select @@tx_islation;
设置隔离级别
set session/global transaction isolation leval 隔离级别;
步骤3:
开启事务:
set autocommit=0;
步骤二:编写sql语句
语句1;
语句2;
步骤3:结束事务
savepoint:节点名,设置保存点

 

posted @ 2022-07-31 16:37  langpo  阅读(53)  评论(0)    收藏  举报