Skip to main content
The System supports multi-statement transactions. By default, a connection uses autocommit mode, in which the database commits each statement immediately. To group several statements into a single transaction, disable autocommit with SET AUTOCOMMIT, and then end the transaction with COMMIT or ROLLBACK.
The HTTP Query API does not support transactions. To use transactions, connect to the Ocient System with the Ocient JDBC driver or the pyocient module.
The Connector supports transactions and performs the commit and rollback actions automatically. When you use the Spark Connector, you do not need to issue COMMIT or ROLLBACK statements.

SET AUTOCOMMIT

Enables or disables autocommit mode for the connection. When autocommit is enabled, the database commits each statement immediately. This mode is the default. When autocommit is disabled, the database groups subsequent statements into a transaction that you complete with the COMMIT or ROLLBACK statements. Valid values are:
  • ON — Enables autocommit mode, in which the database commits each statement immediately. This value is the default.
  • OFF — Disables autocommit mode. The database groups subsequent statements into a transaction until you enter the COMMIT or ROLLBACK statement.
When you change autocommit from OFF to ON, the database commits any pending transactions. After you disable autocommit, ensure that you execute SQL statements that are supported by transactions. Otherwise, the database throws an error. For a list of supported statements, see Transactions. Syntax
SQL
SET AUTOCOMMIT { ON | OFF }
Example This example disables autocommit, inserts two rows into a table, and then commits the transaction to permanently save the rows. Disable autocommit.
SQL
SET AUTOCOMMIT OFF;
Create the public.txn_demo table with two columns: a number and a string.
SQL
CREATE TABLE public.txn_demo (
    id INT,
    term VARCHAR(255));
Insert two rows into the public.txn_demo table and commit these two transactions.
SQL
INSERT INTO public.txn_demo VALUES (1, 'alpha');
INSERT INTO public.txn_demo VALUES (2, 'beta');
COMMIT;
Drop the table.
SQL
DROP TABLE public.txn_demo;

COMMIT

Commits the current transaction and permanently saves all changes made after the transaction started. This statement applies only when you disable autocommit with SET AUTOCOMMIT. When autocommit is enabled, COMMIT has no effect. Syntax
SQL
COMMIT
Example This example disables autocommit, inserts two rows into the public.txn_demo table, and then commits the transaction to permanently save the rows. Disable the autocommit.
SQL
SET AUTOCOMMIT OFF;
Create the public.txn_demo table with two columns: a number and a string.
SQL
CREATE TABLE public.txn_demo (
    id INT,
    term VARCHAR(255));
Insert two rows into the public.txn_demo table and commit these two transactions.
SQL
INSERT INTO public.txn_demo VALUES (1, 'alpha');
INSERT INTO public.txn_demo VALUES (2, 'beta');
COMMIT;
Drop the table.
SQL
DROP TABLE public.txn_demo;

ROLLBACK

Rolls back the current transaction and discards all changes made after the transaction started. This statement applies only when you disable autocommit with SET AUTOCOMMIT. When autocommit is enabled, ROLLBACK has no effect. Syntax
SQL
ROLLBACK
Example This example disables autocommit, inserts two rows in a table, and then rolls back the transaction to discard the inserted rows. Disable the autocommit.
SQL
SET AUTOCOMMIT OFF;
Create the public.txn_demo table with two columns: a number and a string.
SQL
CREATE TABLE public.txn_demo (
    id INT,
    term VARCHAR(255));
Insert two rows into the public.txn_demo table, then roll back both transactions.
SQL
INSERT INTO public.txn_demo VALUES (3, 'gamma');
INSERT INTO public.txn_demo VALUES (4, 'delta');
ROLLBACK;
Drop the table.
SQL
DROP TABLE public.txn_demo;
Data Manipulation Language (DML) Statement Reference Data Query Language (DQL) Statement Reference Data Definition Language (DDL) Statement Reference Commands Supported by the Ocient JDBC CLI Program Ocient Python Module (pyocient)
Last modified on July 2, 2026