云数据库 GAUSSDB-COMMIT | END:示例

时间:2024-11-02 18:52:14

示例

--创建SCHEMA。
openGauss=# CREATE SCHEMA tpcds;

--创建表。
openGauss=# CREATE TABLE tpcds.customer_demographics_t2
(
    CD_DEMO_SK                INTEGER               NOT NULL,
    CD_GENDER                 CHAR(1)                       ,
    CD_MARITAL_STATUS         CHAR(1)                       ,
    CD_EDUCATION_STATUS       CHAR(20)                      ,
    CD_PURCHASE_ESTIMATE      INTEGER                       ,
    CD_CREDIT_RATING          CHAR(10)                      ,
    CD_DEP_COUNT              INTEGER                       ,
    CD_DEP_EMPLOYED_COUNT     INTEGER                       ,
    CD_DEP_COLLEGE_COUNT      INTEGER
)
;

--开启事务。   
openGauss=# START TRANSACTION;

--插入数据。
openGauss=# INSERT INTO tpcds.customer_demographics_t2 VALUES(1,'M', 'U', 'DOCTOR DEGREE', 1200, 'GOOD', 1, 0, 0);
openGauss=# INSERT INTO tpcds.customer_demographics_t2 VALUES(2,'F', 'U', 'MASTER DEGREE', 300, 'BAD', 1, 0, 0);

--提交事务,让所有更改永久化。
openGauss=# COMMIT;

--查询数据。
openGauss=# SELECT * FROM tpcds.customer_demographics_t2;

--删除表tpcds.customer_demographics_t2。
openGauss=# DROP TABLE tpcds.customer_demographics_t2;

--删除SCHEMA。
openGauss=# DROP SCHEMA tpcds CASCADE;
support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_0396.html