How the single SQL statement is isolated?
5
votes
1
answer
865
views
All the books I've seen so far, talking about transactions show scenarios with several SQL statements involved.
But what's about single statements? What level of isolation do they have? Is it specified somewhere in a standard? Or does it depend on RDBMS and isolation level?
Let me show a couple of examples.
1.
UPDATE table SET value = value + 1 WHERE id = 1;
This is a composite read-update-write
operation. Can a parallel transaction change the value between read
and write
operations? Some book states that this operation is atomic (in multithreaded programming meaning) in the _most of the RDBMS_.
2. SELECT * FROM table t1 JOIN table t2 USING (id);
If the table is quite large (or query would have some complicated filtering clause), is it possible at some isolation level that t1.*
and t2.*
columns would differ due to parallel update?
3. SELECT * FROM table1 WHERE id IN (SELECT t_id FROM table2);
Is it possible that some records from table1
are removed after sub-select has been executed? (Here I assume that table2.t_id
references table1.id
with cascaded removal.)
4. CTE...
Links to the useful manuals that fully explain all the details of transactions are also appreciated.
Asked by viator
(151 rep)
Nov 16, 2019, 11:55 AM
Last activity: Nov 16, 2019, 06:02 PM
Last activity: Nov 16, 2019, 06:02 PM