When you commit a transaction, you persist all changes performed in the transaction, delete the savepoints, and release all transaction locks.
To explicitly commit a transaction, use either the COMMIT statement or click the Commit button in the graphic user interface (GUI) tool. Note
OceanBase issues an implicit COMMIT statement before and after a DML statement, which also commits a transaction.
If you use the BEGIN statement to start a new transaction, you must use the COMMIT statement to commit the transaction after executing a DML statement.
Before you commit a transaction:
Your changes are visible to the current session, not others.
Your changes are not final and you can roll them back with a ROLLBACK statement.
After you commit a transaction:
Your changes are visible to all database sessions.
Your changes are persisted and you cannot roll them back with a ROLLBACK statement.
If you do not use an explicit BEGIN statement to start a new transaction, an SQL statement is treated as a transaction and you do not need to commit a transaction. After the SQL statement is executed, your changes are persisted. You cannot roll them back with a ROLLBACK statement.
Example: Committing a transaction
obclient> insert into t_insert(id,name) values(4,'JP');
Query OK, 1 row affected (0.01 sec)
obclient> commit;
Query OK, 0 rows affected (0.00 sec)
obclient> ^Bye
$obclient -h192.168.0.0 -utpcc@obbmsql#obdemo -P2883 -p**1*** TPCC
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient> select * from t_insert;
+----+------+-------+---------------------+
| ID | NAME | VALUE | GMT_CREATE |
+----+------+-------+---------------------+
| 1 | CN | 10001 | 2020-04-02 17:52:31 |
| 2 | US | 10002 | 2020-04-02 17:52:38 |
| 3 | EN | 10003 | 2020-04-02 17:52:38 |
| 4 | JP | NULL | 2020-04-02 17:53:34 |
+----+------+-------+---------------------+
4 rows in set (0.00 sec)