1: 在mysql中,手動提交事務的案例:
CREATE PROCEDURE tfer_funds
(from_account int, to_account int, tfer_amount numeric(10,2))
BEGIN
SET autocommit=0;
UPDATE account_balance SET balance=balance-tfer_amount WHERE account_id=from_account;
UPDATE account_balance SET balance=balance+tfer_amount WHERE account_id=to_account;
COMMIT;
END;
上面就使用了commit
2.要是設置爲手動提交: mysql
在命令行中輸入set autocommit = 0
可是,一旦從新啓動mysql,mysql又默認的autocommit=1;sql