COMMIT

2023-12-25 08:49:42  Updated

Purpose

You can use this statement to commit a transaction, which means to end the transaction and persist all changes executed in the transaction.

After the commit, all savepoints in the transaction are cleared and the transaction lock is released.

Syntax

COMMIT [ WORK ] [ COMMENT 'string' ];

Parameters

Parameter Description
WORK This parameter is optional and is provided for compatibility with SQL standards. The COMMIT; statement is equivalent to the COMMIT WORK; statement.
COMMENT Commits the current transaction and associates a comment with it. This comment can help you diagnose faults of the distributed transaction.
Note: If the distributed transaction cannot be committed due to a network or server fault, OceanBase Database will store the comment and transaction ID in the data dictionary. The comment indicates the faulty application and provides information for contacting the DBA that commits the transaction.

Examples

  • Insert a row into the tbl1 table and commit the change.

    obclient> INSERT INTO tbl1 VALUES (1, 'a',10);
    Query OK, 1 row affected
    
    obclient> COMMIT;
    Query OK, 0 rows affected
    
  • Commit the current transaction and associates a comment with it.

    obclient> COMMIT COMMENT 'Transaction code 001 in question, Please contact Zhang XX';
    Query OK, 0 rows affected
    

Contact Us