2013년 12월 29일 일요일

2_1_autocommit_vs_transaction

mysql 은 auto commit 이 default 로 켜져있다
하지만 start transaction 하게 되면 트랜잭션 모드로 들어간다.

http://dev.mysql.com/doc/refman/5.0/en/commit.html
By default, MySQL runs with autocommit mode enabled. This means that as soon as you execute a statement that updates (modifies) a table, MySQL stores the update on disk to make it permanent.



To disable autocommit mode implicitly for a single series of statements
, use the START TRANSACTION statement:

START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;

확인 방법
select @@autocommit;