Read before write transaction

transaction

Talking about transactions (db transactions), does a read operation have always precede a write operation?

That's obvious, isn't it?

Thanks in advance

*Of course my question doesn't take into account any specific locking protocol or whatever it's actually related to the following question:

A transaction T is defined by a partial order, termed <, such that: 

if r[x] and w[x] belong to T, then r[x] < w[x]. 

Thanks again.

Best Answer

does a read operation have always precede a write operation

Definitely not.

Consider the following transaction:

START TRANSACTION;
UPDATE employee 
   SET salary = null;
COMMIT;

No read done by the transaction controlling code: