READ WRITE is a transaction characteristic defined by the SQL standard. When supplied to START TRANSACTION, BEGIN, or SET TRANSACTION, it tells the database that the current transaction may modify data as well as read it. If omitted, most systems default to READ WRITE, but explicitly declaring it improves clarity and allows code that switches between READ ONLY and READ WRITE for performance or safety reasons.A READ WRITE transaction behaves the same as a default transaction: it acquires any locks required for data changes and is subject to all usual isolation-level rules. The companion keyword READ ONLY tells the optimizer that the transaction will not issue writes, enabling certain optimizations and preventing accidental changes. Switching between the two can be useful in mixed read/write workloads, reporting jobs, and long-running analytical queries.Important caveats:- You must declare READ WRITE (or READ ONLY) before the first query in the transaction block.- Some systems (PostgreSQL, MySQL) allow mixing READ WRITE with ISOLATION LEVEL and access mode in the same statement.- SQL Server does not support the READ WRITE phrase; it relies on implicit write capability or the READ ONLY hint on some statements.- Attempting to change the access mode inside an active transaction usually raises an error.
READ ONLY, START TRANSACTION, SET TRANSACTION, ISOLATION LEVEL, COMMIT, ROLLBACK
SQL-92
Explicitly stating READ WRITE documents intent and contrasts with READ ONLY blocks, making code easier to audit and review.
Issue SET TRANSACTION READ ONLY; before running read-only queries, then start a new transaction with START TRANSACTION READ WRITE; for write operations.
No. Access mode (READ WRITE or READ ONLY) is independent of the isolation level chosen for the transaction.
Negligible. The database already assumes a writable transaction. Declaring it simply records the attribute in the transaction metadata.