Is possible to create atomic transaction in MySQL?
Consider I have table 'category' with these rows:
id|name
--|---------
1 |'tablets'
2 |'phones'
And column name
is my primary key.
If I try:
START TRANSACTION;
update "category" set name = 'phones' where id = 1;
update "category" set name = 'tablets' where id = 2;
COMMIT;
I'm getting:
ERROR: duplicate key value violates unique constraint
"category_name_key"
DETAIL: Key (name)=(tablets) already exists.
My expectation is that constraint checks should be done only during commit. Is this possible with MySQL?