Help Center > > Developer Guide> SQL Reference> SQL Syntax> COMMIT | END

COMMIT | END

Updated at: Jul 15, 2020 GMT+08:00

Function

COMMIT or END commits all operations of a transaction.

Precautions

Only the transaction creators or system administrators can run the COMMIT command. The creation and commit operations must be in different sessions.

Syntax

1
{ 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

    Optional keyword has no effect except increasing readability.

Examples

 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
-- Create a table:
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)
DISTRIBUTE BY HASH (CD_DEMO_SK);

-- Start a transaction:
START TRANSACTION;

-- Insert data:
INSERT INTO tpcds.customer_demographics_t2 VALUES(1,'M', 'U', 'DOCTOR DEGREE', 1200, 'GOOD', 1, 0, 0);
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:
COMMIT;

-- Query data:
SELECT * FROM tpcds.customer_demographics_t2;

-- Delete the tpcds.customer_demographics_t2 table:
DROP TABLE tpcds.customer_demographics_t2;

Helpful Links

ROLLBACK

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel