mysql 设置 手动 COMMIT 的语句!

y2j3 2008-11-11 10:17:54
mysql 设置手动 COMMIT 的语句! 谢谢!!请教大家了
...全文
484 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
y2j3 2008-11-11
  • 打赏
  • 举报
回复
楼主 回复:
谢谢你的回答!
  • 打赏
  • 举报
回复
要是设置为手动提交:
在命令行中输入set autocommit = 0
但是,一旦重新启动mysql,mysql又默认的autocommit=1;
  • 打赏
  • 举报
回复
楼主没说明白,你是要使用commit的语句呢,还是要设置手动提交(因为mysql 自动commit,这你是知道的)

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.要是设置为手动提交:
在命令行中输入set autocommit = 0

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧