1.mysql进行事物操作
关闭autocommit=OFF 写到主配置文件/etc/my.cnf
重启数据库 systemctl restart mariadb
查看修改状态 show variables like 'autocommit'
2.倒数数据
mysql hellodb< testolg.sql
call sp_testlog
因为这个是脚本所以生成100000条数据。
查看生成的数据
select count(*) from testlog;
启动事物begin;
进行删除或者添加记录操作:delete from testlog where id=1;
回滚:rollback;
这里说一下如果回滚失败
回滚失败原因因为我回滚失败一次。
查看下是表格的引擎是不是innodb
如果不是修改一下就可以回滚了
alter table students engine=innoDB;
查看表格的引擎
show create table teslog;