-
SQL - TransactionSQL 2022. 12. 10. 15:45
*transaction
DB에서 쪼갤 수 없는 작업 단위를 뜻한다.
*commit과 rollback
commit : 실행한 쿼리를 확정하는 것
rollback : 실행한 쿼리를 되돌리는 것
autocommit : 실행하면 자동으로 commit 되는 것
select @@autocommit -> autocommit 상태 확인
set autocommit=0; -> autocommit off
set autocommit=1; -> autocommit on
-> DML은 가능하지만 DDL은 되돌릴 수 없다.
-- 1) commit : 실행한 쿼리를 확정 -- auto commit : 쿼리를 실행하면 자동으로 commit하는 것 select @@autocommit; -- 1 : 설정/ 0 : 미설정 set autocommit = 0; -- autocommit off set autocommit = 1; -- autocommit on -- autocommit은 데이터만 한정된다.(insert, delete, update) -- DDL문은 되돌릴 수 없다. (CREATE, ALTER, DROP, TRUNCATE) -- 2) rollback : 실행한 쿼리를 되돌린다. select * from employees e; delete from employees; rollback; insert into employees (emp_no, first_name, family_name, email, mobile) values (200, 'mj','h','hmj@email.com','01012341234'); commit;
'SQL' 카테고리의 다른 글
SQL - 서브쿼리 (0) 2022.12.10 SQL - 제약조건 (0) 2022.12.10 SQL - select문에서의 여러 사용법 (0) 2022.10.07 SQL - DML (0) 2022.10.07 SQL - DDL (0) 2022.10.07