Transactions
A transaction is a sequence of SQL operations that starts with the START TRANSACTION
statement and ends with the COMMIT
statement. Either the effect of all operations will be published, or no results will be published at all.
Note
|
Transactions are only allowed within a script. |
In Ignite 3, you start the transaction by using the START TRANSACTION
statement:
Diagram( Terminal('START TRANSACTION'), ZeroOrMore( Terminal('READ ONLY'), Terminal('READ WRITE')))
Note
|
DDL statements are not supported inside transactions. |
Parameters:
-
READ WRITE
- both read and write operations are allowed in the transaction. -
READ ONLY
- only read operations are allowed in the transaction.
You close and commit the transaction by using the COMMIT
statement:
Diagram( Terminal('COMMIT'))
Example
The example below inserts 3 lines into the table in a single transaction, ensuring they will all be committed together:
START TRANSACTION READ WRITE;
INSERT INTO Person (id, name, surname) VALUES (1, 'John', 'Smith');
INSERT INTO Person (id, name, surname) VALUES (2, 'Jane', 'Smith');
INSERT INTO Person (id, name, surname) VALUES (3, 'Adam', 'Mason');
COMMIT;
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.