BEGIN;
UPDATE foo SET bar = 3;
UPDATE bar SET thing = 5;
COMMIT;
, . ROLLBACK, - .
MySQL, . . docs DECLARE HANDLER. , , SQLEXCEPTION. .
, , - , , . , MySQL ( ).
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION ROLLBACK;
START TRANSACTION;
UPDATE foo SET bar = 3;
UPDATE bar SET thing = 5;
COMMIT;
END;
:
, . ; , - .
, "" , "" MySQL. - "", . , COMMIT, ROLLBACK .
, MySQL - , ( - ). MySQL , .
Finally, you can completely disable this behavior, and then you must constantly use transactions. I believe that "BEGIN" has been implied since the last execution or rollback, but you must either COMMIT or ROLLBACK any requests you requested.
For more information, see the InnoDB Transaction Model in the MySQL Guide.
source
share