说明
在删除audsys下的表时报错
bash
ORA-55941: 不允许对表 "AUDSYS"."CLI_SWP$233f2a8a$1$1" 执行 DML 和 DDL 操作
解决方案
扩展
定期PURGE部分AUD$
第一步针对AUDIT_TRAIL_AUD_STD设置init_cleanup每24小时执行一次.
sql
BEGIN
IF NOT DBMS_AUDIT_MGMT.IS_CLEANUP_INITIALIZED
(DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD)
THEN
dbms_output.put_line('Calling DBMS_AUDIT_MGMT.INIT_CLEANUP');
DBMS_AUDIT_MGMT.INIT_CLEANUP(
audit_trail_type => dbms_audit_mgmt.AUDIT_TRAIL_AUD_STD,
default_cleanup_interval => 24);
else
dbms_output.put_line('Cleanup for STD was already initialized');
end if;
end;
/
第二步 设置为超过14天审计记录标记时间戳.
--这里的时间戳需要注意,如果 AUDIT_TRAIL_TYPE为OS或者XML格式,则需要使用本地系统时间的格式,其他2种格式为UTC.
sql
begin
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
last_archive_time => sysdate - 14);
end;
/
第三步 设置DBMS_AUDIT_MGMT过程中的purge_job
sql
BEGIN
DBMS_AUDIT_MGMT.CREATE_PURGE_JOB (
AUDIT_TRAIL_TYPE => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
AUDIT_TRAIL_PURGE_INTERVAL => 24,
AUDIT_TRAIL_PURGE_NAME => 'AUD_PURGE',
USE_LAST_ARCH_TIMESTAMP => TRUE );
END;
/
第四步创建DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP定期推进审计记录的归档时间戳的存储过程.
sql
create or replace procedure set_archive_timestamp (retention in number default 14) as
begin
DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,last_archive_time => sysdate -- retention);
end;
/
第五步 创建schedul,设置每6小时执行一次存储过程set_archive_timestamp
sql
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'PUSH_AUD_ARCH_TSTAMP',
job_type => 'STORED_PROCEDURE',
job_action => 'SET_ARCHIVE_TIMESTAMP',
number_of_arguments => 1,
start_date => SYSDATE,
repeat_interval => 'freq=hourly;interval=6',
enabled => false,
auto_drop => FALSE);
End;
/
BEGIN
dbms_scheduler.set_job_argument_value
(job_name =>'PUSH_AUD_ARCH_TSTAMP',
argument_position =>1,
argument_value => 7);
DBMS_SCHEDULER.ENABLE('PUSH_AUD_ARCH_TSTAMP');
End;
/
设置完成,执行一次.
sql
BEGIN
DBMS_SCHEDULER.run_job (job_name => 'PUSH_AUD_ARCH_TSTAMP',
use_current_session => FALSE);
END;
/