No. Single update statements are atomic and there is no order in their individual parts.
Both of these:
update abc set A = B, B = 0 where A=1
update abc set B = 0, A = B where A=1
do exactly the same thing because the two assignments are considered to happen concurrently.
In other words, B
on the right side of =
is the old value of B
.
Addendum: How a DBMS implements this behaviour depends on the cleverness of those writing the DBMS.
For example a DBMS might attempt to lock all the rows where A
is 1 then, once that's done, go through and execute A = B
, B = 0
(in that order because the execution engine deems that will satisfy concurrency, setting A
to B
before changing B
) on each of those rows.
A statement like set A = B, B = A
would require somewhat more intelligence but it could do that easily enough by saving the current row first and using values there to set values in the new row, something like:
read in oldrow
copy oldrow to newrow
newrow.A = oldrow.B
newrow.B = oldrow.A
write out newrow
Then it will unlock all the rows.
That's just one option. A very dumb DBMS may just lock the entire database file although that wouldn't make for very intelligent concurrency.
A single-user, single-thread DBMS doesn't have to care about concurrency at all. It would lock absolutely nothing, just going through each relevant row, making the changes.