BEGIN
statementsupportedQueries & DMLBegins a transaction in the current session. START TRANSACTION is a synonym for BEGIN.
Syntax
supportedpartialnot supportednot scored
BEGIN [ { WORK | TRANSACTION } ] [ NAME <name> ]
START TRANSACTION [ NAME <name> ]
Parameters
| Name | Required | Description |
|---|---|---|
WORK | TRANSACTION | Optional keywords that provide compatibility with other database systems. | |
NAME name | Optional string that assigns a name to the transaction. A name helps identify a transaction, but is not required and does not need to be unique. |
Usage notes
- All transactions have a system-generated internal ID. The transaction ID is a signed 64-bit (long) integer. The range of values is -9,223,372,036,854,775,808 (-2 63) to 9,223,372,036,854,775,807 (2 63 - 1).
- If you specify a name for a transaction, the NAME keyword is required.
- If a name is not specified, a system-generated name is assigned to the transaction.
- To complete a transaction, a COMMIT or ROLLBACK command must be explicitly executed. Until one of these commands is executed, the transaction remains open.
- When a SQL statement queries a stream within an explicit transaction, the stream is queried at the stream advance point (i.e. the timestamp) when the transaction began rather than when the statement was run. This behavior pertains both to DML statements and CREATE TABLE … AS SELECT (CTAS) statements that populate a new table with rows from an existing stream.
- If two BEGIN statements in a row are executed (within the same scope), the second one is ignored. For example, in the following code, the second and third BEGINs have no effect; the existing open transaction continues. Copy code BEGIN; BEGIN; -- Ignored! INSERT INTO table1 ...; BEGIN; -- Ignored! INSERT INTO table2 ...; COMMIT; The rules can be more complex if you are using autonomous scoped transactions and stored procedures.