分类:
2012-06-13 22:14:14
-- Create table
--建立一个监控表
create table DDL_LOG
(
USER_NAME VARCHAR2(30),
DDL_DATE DATE,
DDL_TYPE VARCHAR2(30),
OBJECT_TYPE VARCHAR2(18),
OWNER VARCHAR2(30),
OBJECT_NAME VARCHAR2(128),
IP_ADDRESS VARCHAR2(40),
OSUSER VARCHAR2(30),
TERMINAL VARCHAR2(30)
);
--创建触发器
CREATE OR REPLACE TRIGGER ddl_trigger
AFTER DDL
ON DATABASE
BEGIN
INSERT INTO ddl_log
(user_name,
ddl_date,
ddl_type,
object_type,
owner,
object_name,
ip_address,
osuser,
terminal)
VALUES
(ora_login_user,
SYSDATE,
ora_sysevent,
ora_dict_obj_type,
ora_dict_obj_owner,
ora_dict_obj_name,
SYS_CONTEXT('USERENV', 'IP_ADDRESS'),
SYS_CONTEXT('USERENV', 'OS_USER'),
SYS_CONTEXT('USERENV', 'TERMINAL'));
END ddl_trigger;