COMMIT | END

Function

COMMIT or END commits all operations of a transaction.

Precautions

Only the creator of a transaction or a system administrator can run the COMMIT command. The creation and commit operations must be in different sessions.

Syntax

{ COMMIT | END } [ WORK | TRANSACTION ] ;

Parameter Description

  • COMMIT | END

    Commits the current transaction and makes all changes made by the transaction become visible to others.

  • WORK | TRANSACTION

    Specifies an optional keyword, which has no effect except increasing readability.

Examples

-- Create a table.
postgres=# 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
)
WITH (ORIENTATION = COLUMN,COMPRESSION=MIDDLE)
;

-- Start a transaction.
postgres=# START TRANSACTION;

-- Insert data.
postgres=# INSERT INTO tpcds.customer_demographics_t2 VALUES(1,'M', 'U', 'DOCTOR DEGREE', 1200, 'GOOD', 1, 0, 0);
postgres=# INSERT INTO tpcds.customer_demographics_t2 VALUES(2,'F', 'U', 'MASTER DEGREE', 300, 'BAD', 1, 0, 0);

-- Commit the transaction to make all changes permanent.
postgres=# COMMIT;

-- Query data.
postgres=# SELECT * FROM tpcds.customer_demographics_t2;

-- Delete the tpcds.customer_demographics_t2 table.
postgres=# DROP TABLE tpcds.customer_demographics_t2;

Helpful Links

ROLLBACK

Feedback
编组 3备份
    openGauss 2024-05-06 00:44:54
    cancel