START TRANSACTION
delete from t_emp
delete from t_dept
commit
START TRANSACTION
delete from t_emp
delete from t_dept
SELECT * FROM t_emp 查询不到数据
SELECT * FROM t_dept 查询不到数据
-- commit
ROLLBACK
SELECT * FROM t_emp 有数据
SELECT * FROM t_dept 有数据
设置事务级别
SERIALIZABLE 序列号执行 等之前的事务结束了, 再执行现在的事务
REPEATABLE READ 代表事务在执行中反复读取数据 得到的结果是一致的 用户商城 商品 如果涨价, 用户购买价格是 涨价之前的
READ COMMITTED 代表只能读取其他事务提交的数据 用户账户转账类型的
READ UNCOMMITTED 用于买票类型的
set session TRANSACTION ISOLATION LEVEL READ UNCOMMITTED 用于买票类型的