自己安装的openGauss环境
启动openGauss
gs_ctl -D /gauss/data/db1/ start
登录openGauss
gsql -d postgres -p 26000 -r
1.以默认方式启动事务1,修改事务隔离级别,查看transaction_isolation
START TRANSACTION;
show transaction_isolation;
SET LOCAL TRANSACTION ISOLATION LEVEL repeatable read;
show transaction_isolation;
rollback;
2.以读写方式启动事务2,创建新表,修改事务为只读事务,查看transaction_read_only,并向表中插入记录
START TRANSACTION ISOLATION LEVEL repeatable read READ WRITE;
show transaction_read_only;
create table products
(product_id INTEGER,
product_name Char(30)
);
SET LOCAL TRANSACTION ISOLATION LEVEL repeatable read READ ONLY;
show transaction_read_only;
insert into products(product_id,product_name) values(1,‘des’);
commit;
3.启动事务3,对表进行增删改查,并用到创建savepoint,回滚savepoint和删除savepoint
create table products
(product_id INTEGER,
product_name Char(30)
);
START TRANSACTION;
insert into products(product_id,product_name) values(1,‘des’);
select * from products;
savepoint products_point;
delete from products;
select * from products;
rollback to savepoint products_point;
select * from products;
RELEASE savepoint products_point;
insert into products(product_id,product_name) values(2,‘modify’);
commit;
select * from products
4.清理数据
drop table products;