DELETE문과 같이 정리
■ SAVEPOINT
DML작업시에 ROLLBACK을 도와주는 표시자
SAVEPOINT 표시자 ;
ROLLBACK TO 표시자;
예)
1) INSERT INTO employees (employee_id, last_name, department_id) VALUES (9999, ‘Smith’, 10);
2) DELETE employees WHERE employee_id = 100;
3) UPDATE employees SET last_name = ‘Clark’;
4) INSERT INTO employees (employee_id, last_name, department_id) VALUES (8888, ‘Thomas’, 30);
5) DELETE employees WHERE department_id = 20;
ROLLBACK; --> 1번 transaction 시작 시점부터 전부 취소
예)
1) INSERT INTO employees (employee_id, last_name, department_id) VALUES (9999, ‘Smith’, 10);
2) DELETE employees WHERE employee_id = 100;
SAVEPOINT A;
3) UPDATE employees SET last_name = ‘Clark’;
4) INSERT INTO employees (employee_id, last_name, department_id) VALUES (8888, ‘Thomas’, 30);
SAVEPOINT B;
5) DELETE employees WHERE department_id = 20;
ROLLBACK TO B; --> 5번 취소
ROLLBACK A; --> 3,4,5번 취소
COMMIT; --> 1,2 transaction 영구히 저장
'Oracle SQL' 카테고리의 다른 글
15 PL/SQL WHILE LOOP, FOR, Implicit Cursor (1) | 2023.10.26 |
---|---|
14 PL/SQL Variable, CASE, LOOP (0) | 2023.10.25 |
12 Sequence, Synonym, Extract, 날짜함수, 분석함수, Rank (0) | 2023.10.23 |
11 Unique, Check, Not Null, Rename, Flashback, Truncate, Comment, View (0) | 2023.10.20 |
10 Subquery, Merge, Primary Key, Foreign Key (0) | 2023.10.19 |