[Oracle] 감사(audit) 옵션 지정

·2025년 9월 5일

오라클 관리

목록 보기
101/163

[실습1] sys 유져에서 scott 의 emp 테이블에 대해서 select 를 했을때 감사되게 하시오

SYS @ ora19dw > show user
USER"SYS"입니다
SYS @ ora19dw >
SYS @ ora19dw > audit select on scott.emp;

감사 성공입니다.

scott 유져에서 다음과 같이 emp 테이블을 select 합니다.

select ename, sal from emp;

sys 유져에서 감사로그를 확인합니다.


문제1. scott이 가지고 있는 모든 테이블들에 대해서 select 했을 때 감사가 되게하시오

sys 에서 다음의 작업을 수행합니다.

select  username, timestamp, action_name, obj_name,terminal 
from  dba_audit_trail;

select 'audit select on scott.' || lower(table_name) || ';'
 from dba_tables 
 where owner='SCOTT';
 
audit select on scott.emp;
audit select on scott.mcustsum;
audit select on scott.emp01;
audit select on scott.emp501;
audit select on scott.emp105;
audit select on scott.emp200;
audit select on scott.dept200;

pl/sql로 하고 싶다면?

BEGIN   
FOR t IN (SELECT table_name FROM all_tables WHERE owner = 'SCOTT') LOOP      
   EXECUTE IMMEDIATE 'AUDIT SELECT ON SCOTT.' || t.table_name;   
   END LOOP;
END;
/

0개의 댓글