openGauss 每日一练第 16 天打卡,我来了!又可以学习,真开心~
学习
今天第 16 课,学习openGauss事务控制。
事务是用户定义的一个数据库操作序列,这些操作要么全做要么全不做,是一个不可分割的工作单位!
课后作业打卡
1.以默认方式启动事务1,修改事务隔离级别,查看transaction_isolation
1 2 3 4
| start transaction; SET LOCAL TRANSACTION ISOLATION LEVEL READ COMMITTED READ ONLY; show transaction_isolation; END;
|

2.以读写方式启动事务2,创建新表,修改事务为只读事务,查看transaction_read_only,并向表中插入记录
1 2 3 4 5 6 7
| show transaction_isolation; START TRANSACTION ISOLATION LEVEL repeatable read READ WRITE; create table lucifer(id int,name char(20)); SET LOCAL TRANSACTION ISOLATION LEVEL READ COMMITTED READ ONLY; show transaction_read_only; insert into lucifer values(1,'Lucifer'); commit;
|

3.启动事务3,对表进行增删改查,并用到创建savepoint,回滚savepoint和删除savepoint
1 2 3 4 5 6 7 8 9 10 11
| START TRANSACTION; create table lucifer(id int,name char(20)); insert into lucifer values(1,'Lucifer'); select * from lucifer; SAVEPOINT my_savepoint; delete from lucifer where id = 1; ROLLBACK TO SAVEPOINT my_savepoint; update lucifer set name = 'Lucifer1' where id = 1; RELEASE SAVEPOINT my_savepoint; COMMIT; select * from lucifer;
|

4.清理数据
写在最后
今天的作业打卡结束!🎉