START TRANSACTION
Start the transaction block.
Summary
START TRANSACTION [transaction_mode] [READ WRITE | READ ONLY]
Where transaction_mode is:
ISOLATION LEVEL {SERIALIZABLE | READ COMMITTED | READ UNCOMMITTED}
describe
START TRANSACTION starts a new transaction block. If an isolation level or read/write mode is specified, the new transaction has those characteristics, just like the SET TRANSACTION is performed. This is the same as the BEGIN command.
Parameters
READ UNCOMMITTED
READ COMMITTED
REPEATABLE READ
SERIALIZABLE
- The SQL standard defines four transaction isolation levels: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ and SERIALIZABLE.
- READ UNCOMMITTED allows transactions to view changes made by uncommitted concurrent transactions. This is not possible in the YMatrix database, so READ UNCOMMITTED is the same as READ COMMITTED.
- READ COMMITTED is the default isolation level in the YMatrix database, ensuring that statements can only see rows submitted before they begin. If another concurrent transaction is submitted after the first execution of the statement, the same statement executed twice in one transaction may produce different results.
- REPEATABLE READ isolation level ensures that transactions can only see rows committed before the transaction begins. REPEATABLE READ is the strictest level of transaction isolation supported by YMatrix databases. Due to serialization failure, applications that use REPEATABLE READ isolation level must be prepared to retry the transaction.
- SERIALIZABLE transaction isolation level ensures that execution of multiple concurrent transactions has the same effect as running these transactions in a serial way. If SERIALIZABLE is specified, the YMatrix database will fall back to REPEATABLE READ.
READ WRITE
READ ONLY
- Determine whether a transaction is read/write or read-only. Read/write is the default setting. When the transaction is read-only, the following SQL commands are not allowed: INSERT, UPDATE, DELETE, and COPY FROM (if the table to be written is not a temporary table); all CREATE, ALTER and DROP commands; GRANT, REVOKE, TRUNCATE; if the commands to be executed by EXPLAIN ANALYZE and EXECUTE are not allowed in the above commands, they are not allowed. and EXPLAIN ANALYZE and EXECUTE if they are to execute the commands among the listed commands.
Example
Start a transaction block:
START TRANSACTION;
compatibility
In the standard, it is not necessary to issue START TRANSACTION to start a transaction block: any SQL command implicitly starts a block. YMatrix database behavior can be seen as implicit issuing COMMIT after each command that does not follow START TRANSACTION (or BEGIN), so it is often referred to as "auto-commit". Other relational database systems may provide convenient automatic submission.
See also
BEGIN, SET TRANSACTION