I have two tables t1 and t2 with primary key id
and integer amount
each.
I need to "move" amounts from t2 to t1, but not lost any amounts and not get extra. Is it possible by single update with autocommit and without transaction isolations?
I mean something like this:
update t1 join t2 using (id)
set t1.amount = t1.amount + t2.amount, t2.amount = 0;
Is it guaranteed that total amount will not be changed by this statement? Or it's possible (if change t2.amount
during this execution or interrupt it) that t1.amount
increase by not the same value that t2.amount
decrease?