记录oracle数据库库表变动Oracle认证考试
文章作者 100test 发表时间 2010:02:02 16:20:04
来源 100Test.Com百考试题网
触发器:
CREATE OR REPLACE TRIGGER tr_trace_ddl
AFTER DDL ON DATABASE
DECLARE
sql_text ora_name_list_t.
state_sql ddl$trace.ddl_sql%TYPE.
BEGIN
FOR i IN 1..ora_sql_txt(sql_text) LOOP
state_sql := state_sql||sql_text(i).
END LOOP.
INSERT INTO ddl$trace(login_user,ddl_time,ip_address,audsid,
schema_user,schema_object,ddl_sql)
valueS(ora_login_user,SYSDATE,userenv( SESSIONID ),
sys_context( USERENV , IP_ADDRESS ),
ora_dict_obj_owner,ora_dict_obj_name,state_sql).
--EXCEPTION
--WHEN OTHERS THEN
--sp_write_log( Capture DDL Excption: ||SQLERRM).
END tr_trace_ddl.
日志表结构:
create table DDL$TRACE
(
LOGIN_USER