I have multiple mysql InnoDb tables, I am trying to alter/insert/modify many of them in a sql transaction, I set autocommit to false, so that if some sql statements fail, I do commit the rest of statements:
set autocommit = 0;
START TRANSACTION;
use database1;
update table1 set tkey = '3' .....;
update table1 set tkey = '4' .......;
update table1 set tkey = '5' .......;
update table1 set tkey = '6' .......;
ALTER TABLE table2 ADD COLUMN ..... bool NOT NULL; -- This fails
COMMIT;
In above transaction the alter table2 fails, but still the updates to table 1 have happened, how can I avoid that? I want a rolllback even if one statement fails.
Aucun commentaire:
Enregistrer un commentaire