basic SQL atomicity "UPDATE ... SET .. WHERE ..."

Posted by elgcom on Stack Overflow See other posts from Stack Overflow or by elgcom
Published on 2010-04-19T14:28:10Z Indexed on 2010/04/19 14:43 UTC
Read the original article Hit count: 309

Filed under:
|

I have a rather basic and general question about atomicity of "UPDATE ... SET .. WHERE ..." statement.

having a table (without extra constraint),

+----------+
| id | name|
+----------+
|  1 |  a  |
+----+-----+

now, I would execute following 4 statements "at the same time" (concurrently).

UPDATE table SET name='b1' WHERE name='a'
UPDATE table SET name='b2' WHERE name='a'
UPDATE table SET name='b3' WHERE name='a'
UPDATE table SET name='b4' WHERE name='a'

is there only one UPDATE statement would be executed with table update? or, is it possible that more than one UPDATE statements can really update the table?

should I need extra transaction or lock to let only one UPDATE write values into table?

thanks

© Stack Overflow or respective owner

Related posts about sql

Related posts about atomicity