Help Center > > Developer Guide> SQL Reference> SQL Syntax> START TRANSACTION

START TRANSACTION

Updated at: Mar 13, 2020 GMT+08:00

Function

START TRANSACTION starts a transaction. If the isolation level, read/write mode, or deferrable mode is specified, a new transaction will have those characteristics. You can also specify them using SET TRANSACTION.

Precautions

None

Syntax

Format 1: START TRANSACTION

1
2
3
4
5
6
7
START TRANSACTION
  [ 
    { 
       ISOLATION LEVEL { READ COMMITTED | READ UNCOMMITTED | SERIALIZABLE | REPEATABLE READ }
       | { READ WRITE | READ ONLY }
     } [, ...] 
  ];

Format 2: BEGIN

1
2
3
4
5
6
7
BEGIN [ WORK | TRANSACTION ]
  [ 
    { 
       ISOLATION LEVEL { READ COMMITTED | READ UNCOMMITTED | SERIALIZABLE | REPEATABLE READ }
       | { READ WRITE | READ ONLY }
      } [, ...] 
  ];

Parameter Description

  • WORK | TRANSACTION

    Optional keyword in BEGIN format without functions.

  • ISOLATION LEVEL

    Specifies the transaction isolation level that determines the data that a transaction can view if other concurrent transactions exist.

    The isolation level of a transaction cannot be reset after the first clause (INSERT, DELETE, UPDATE, FETCH, COPY) for modifying data is executed in the transaction.

    Valid value:

    • READ COMMITTED: Only committed data is read. This is the default.
    • READ UNCOMMITTED: DWS does not support READ UNCOMMITTED. If READ UNCOMMITTED is set, READ COMMITTED is executed instead.
    • REPEATABLE READ: Only the data committed before transaction start is read. Uncommitted data or data committed in other concurrent transactions cannot be read.
    • SERIALIZABLE: DWS does not support SERIALIZABLE. If SERIALIZABLE is set, REPEATABLE READ is executed instead.
  • READ WRITE | READ ONLY

    Specifies the transaction access mode (read/write or read only).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
-- Start a transaction in default mode:
START TRANSACTION;
SELECT * FROM tpcds.reason;
END;

-- Start a transaction in default mode:
BEGIN;
SELECT * FROM tpcds.reason;
END;

-- Start a transaction with the isolation level being READ COMMITTED and the access mode being READ WRITE:
START TRANSACTION ISOLATION LEVEL READ COMMITTED READ WRITE;
SELECT * FROM tpcds.reason;
COMMIT;

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