Develope/교육

[Oracle] 교육 6일차) DML, DDL, 커밋 이전 조회 (플래시백)

고로이 2018. 10. 5. 15:20
반응형

왜이걸 이제 배우지?ㅋㅋㅋ


원래 제일먼저 배우지 않나 ㅋㅋㅋ






* DML => rollback 가능=]]


- INSERT 

INSERT INTO table_name 

(col1, col2, ... colN )

VALUES

('11', 22, .. , NN)


* select Insert 가능

INSERT INTO emp_new 

VALUES (select * from employees where salary < 5000)


- UPDATE 

UPDATE table_name

SET col1= 111, col2 = 222, col3 = 333

WHERE colN = NNN


역시나 select update 가능

update emp_new 

set e.department_name = (select d2.department_name from departments d2 where d2.department_id = e.department_id)


- DELETE 



* DDL 

- CREATE

- ALTER

- DROP



- TRUNCATE

TRUNACATE TABLE table_name 


****** truncate 실행 시 자동 커밋된다. 이전에 실행한 DML 작업이 있으면 자동으로 커밋된다..





** 커밋 이후 데이터를 살리는 방법 (오라클 10g 이후) => 플래시백 **

SELECT *

FROM dept_new as of timestamp to_date('2018/10/05 15:10:44', 'yyyy/mm/dd hh24:mi:ss');



=>조금 변형

SELECT *

FROM dept_new as of timestamp to_date('2018/10/05 14:10:44', 'yyyy/mm/dd hh24:mi:ss')

WHERE department_id not in (select d2.department_id from dept_new d2)



=> 시간을 지정하지 않고 거슬러가는법
SELECT
FROM dept_new as of timestamp sysdate- 10/1440


----emp는 왜 안돼징


ORA-01466: unable to read data - table definition has changed

01466. 00000 -  "unable to read data - table definition has changed"

*Cause:    Query parsed after tbl (or index) change, and executed

           w/old snapshot

*Action:   commit (or rollback) transaction, and re-execute

반응형