AUTOCOMMIT

When AUTOCOMMIT is set 'on', each SQL command is automatically committed upon successful completion; for example:.

When AUTOCOMMIT is set 'on', each SQL command is automatically committed upon successful completion; for example:

\set AUTOCOMMIT on

To postpone COMMIT in this mode, set the value as off.

\set AUTOCOMMIT off

If AUTOCOMMIT is empty or defined as off, SQL commands are not committed unless you explicitly issue COMMIT.

Notes

  • AUTOCOMMIT is off by default.

  • AUTOCOMMIT must be in uppercase, but the values, on or off, are case insensitive.

  • In autocommit-off mode, you must explicitly abandon any failed transaction by entering ABORT or ROLLBACK.

  • If you exit the session without committing, your work is rolled back.

  • Validation on vsql variables is done when they are run, not when they are set.

  • The COPY statement, by default, commits on completion, so it does not matter which AUTOCOMMIT mode you use, unless you issue COPY NO COMMIT. Please note that DDL statements are autocommitted.

  • To tell if AUTOCOMMIT is on or off, issue the set command:

    $ \set...
    AUTOCOMMIT = 'off'
    ...
    
  • AUTOCOMMIT is off if a SELECT * FROM LOCKS shows locks from the statement you just ran.

    $ \set AUTOCOMMIT off
    $ \set
    ...
    AUTOCOMMIT = 'off'
    ...
    SELECT COUNT(*) FROM customer_dimension;
     count
    -------
     50000
    (1 row)
    SELECT node_names, object_name, lock_mode, lock_scope
    FROM LOCKS;
     node_names |      object_name         | lock_mode | lock_scope
    ------------+--------------------------+-----------+-------------
     site01     | Table:customer_dimension | S         | TRANSACTION
    (1 row)