云数据库 GAUSSDB-RELEASE SAVEPOINT:示例
时间:2025-03-12 13:57:24
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
--创建SCHEMA。 openGauss=# CREATE SCHEMA tpcds; --创建一个新表。 openGauss=# CREATE TABLE tpcds.table1(a int); --开启事务。 openGauss=# START TRANSACTION; --插入数据。 openGauss=# INSERT INTO tpcds.table1 VALUES (3); --建立保存点。 openGauss=# SAVEPOINT my_savepoint; --插入数据。 openGauss=# INSERT INTO tpcds.table1 VALUES (4); --删除保存点。 openGauss=# RELEASE SAVEPOINT my_savepoint; --提交事务。 openGauss=# COMMIT; --查询表的内容,会同时看到3和4。 openGauss=# SELECT * FROM tpcds.table1; --删除表。 openGauss=# DROP TABLE tpcds.table1; --删除SCHEMA。 openGauss=# DROP SCHEMA tpcds CASCADE; |
support.huaweicloud.com/distributed-devg-v2-gaussdb/gaussdb-12-0436.html