Can changes made in one transaction “see” each other?

Suppose I make the following set of SQL queries (pseudo-code) in a table with only one column CITY:

BEGIN TRANSACTION;
INSERT INTO MyTable VALUES( 'COOLCITY' );
SELECT * FROM MyTable WHERE ALL;
COMMIT TRANSACTION;

is SELECTguaranteed return COOLCITY?

+5
source share
1 answer

Yes.

The operation INSERTwill block Xat least the newly added row. This will not be released until the end of the transaction, thereby preventing the deletion or updating of the parallel transaction of this row.

A transaction is not blocked by its own locks, therefore SELECTreturns COOLCITY.

+6

All Articles