select ename, sal, job
from emp
where job='SALESMAN'
for update wait 60;
๐ก
for update wait 60
: 60์ด๋์ ๋ฝ(lock)์ ๊ฑธ๊ฒ ๋ค
(๋ค๋ฅธ ์ธ์ ์ด ํน์ update๋ฅผ ํ๊ฒ ๋๋ฉด 60์ด๋ง ๊ธฐ๋ค๋ฆฌ๋ฉด ํ๋ฆฌ๊ฒ ํ๊ฒ ๋ค)
๐ก dba๊ฐ ๋ฝ(lock)๋ฌธ์ ๊ฐ db์ ์์ฃผ ๋ฐ์ํด์ ๋ฝ์ผ๋ก ์ธํด ์ฑ๋ฅ์์ ๋ฌธ์ ๊ฐ ์์ฃผ ์๊ธด๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ ์กฐ์น๋ฅผ ์ทจํ ์ ์์. ํน์ ์ธ์ ์ด ์์ ํ ๋ ์๋ ์ปค๋ฐ๊ธฐ๋ฅ์ ์ด์ฉํ๊ฒ๋ ๊ถ์ฅํ ์ ์์
-- ์๋์ปค๋ฐ ๊ธฐ๋ฅ ํ์ธ
show autocommit;
-- ์๋์ปค๋ฐ ๊ธฐ๋ฅ ์ผฌ
set autocommit on;
show autocommit;
-- ์๋์ปค๋ฐ ๋จ
update emp
set sal = 0
where ename='ALLEN';
-- ์๋์ปค๋ฐ ๊ธฐ๋ฅ ๋
set autocommit off;
show autocommit;
๐ก ์ค๋ผํด์ autocommit์ด ์๋์ผ๋ก ์ผ์ ธ์์ง ์์๋ฐ
mysql์ default๊ฐ autocommit์ด ์๋์ผ๋ก ์ผ์ ธ์์