Purge the Audit records with truncate or DBMS_AUDIT_MGMT package (2024)

Purge the Audit records with truncate or DBMS_AUDIT_MGMT package

Check AUDIT is enabled or disabled

Show parameter audit_trail

NAME TYPE VALUE------------- ------- --------audit_trail string DB

Check total no of rows in Audit table

select count(*) TOTAL from sys.aud$;

Check the size of AUD$ table

select owner,segment_name,segment_type,tablespace_name,bytes/1024/1024 "MB Size" from dba_segments where segment_name='AUD$';

 OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME MB Size----- ------------ ------------ --------------- -------SYS AUD$ TABLE SYSTEM 550

Purge the AUDIT records Manually

--For complete purging the AUDIT table.
TRUNCATE table sys.AUD$;

--Delete all data from AUD$ except keeping last 30 days
--disable the aud$ logging otherwise it generate lot of archive logs
alter table AUD$ nologging;
delete from aud$ where TIMESTAMP# <= sysdate-30;

Purge the Audit records with Package DBMS_AUDIT_MGMT

1. Check the configuration

COLUMN parameter_name FORMAT A30
COLUMN parameter_value FORMAT A20
COLUMN audit_trail FORMAT A20
SELECT * FROM dba_audit_mgmt_config_params;

 PARAMETER_NAME PARAMETER_VALUE AUDIT_TRAIL------------------------------ -------------------- --------------------AUDIT FILE MAX SIZE 10000 OS AUDIT TRAILAUDIT FILE MAX SIZE 10000 XML AUDIT TRAILAUDIT FILE MAX SIZE 10000 UNIFIED AUDIT TRAILAUDIT FILE MAX AGE 5 OS AUDIT TRAILAUDIT FILE MAX AGE 5 XML AUDIT TRAILAUDIT FILE MAX AGE 5 UNIFIED AUDIT TRAILDB AUDIT TABLESPACE TS_AUDIT STANDARD AUDIT TRAILDB AUDIT TABLESPACE SYSAUX FGA AUDIT TRAILDB AUDIT TABLESPACE SYSAUX UNIFIED AUDIT TRAILDB AUDIT CLEAN BATCH SIZE 10000 STANDARD AUDIT TRAILDB AUDIT CLEAN BATCH SIZE 10000 FGA AUDIT TRAILOS FILE CLEAN BATCH SIZE 1000 OS AUDIT TRAILOS FILE CLEAN BATCH SIZE 1000 XML AUDIT TRAILAUDIT WRITE MODE QUEUED WRITE MODE UNIFIED AUDIT TRAIL

2. Clear the Audit Record initially

--- Clean initially
BEGIN
DBMS_AUDIT_MGMT.INIT_CLEANUP( audit_trail_type => dbms_audit_mgmt.AUDIT_TRAIL_AUD_STD, default_cleanup_interval => 12);
end;
/
Note: If you haven’t moved the AUD$ table out of SYSTEM tablespace, then it the below script will move the AUD$ to SYSAUX tablespace by default.

--Check first step is completed YES
SET SERVEROUTPUT ON
BEGIN
IF DBMS_AUDIT_MGMT.is_cleanup_initialized(DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD) THEN
DBMS_OUTPUT.put_line('YES');
ELSE
DBMS_OUTPUT.put_line('NO');
END IF;
END;
/

--Set the last archive timestamp to remove the audit records lower than value of it. i keep 30 days data for aud$ table.
BEGIN
DBMS_AUDIT_MGMT.set_last_archive_timestamp(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
last_archive_time => SYSTIMESTAMP-30);
END;
/

--Verify
SELECT * FROM dba_audit_mgmt_last_arch_ts;

For complete empty the AUD$ table from DBMS package

BEGIN
DBMS_AUDIT_MGMT.clean_audit_trail(
audit_trail_type => DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD,
use_last_arch_timestamp => TRUE);
END;
/

For Enable or Disable the Audit at Database Level

--For Enable
ALTER SYSTEM SET audit_trail=db SCOPE=SPFILE;
--For Disable
ALTER SYSTEM SET audit_trail=NONE SCOPE=SPFILE;

Scheduled the Job of Audit purging in DBMS SCHEDULER JOBS

-- Create the scheduler job which purge the AUD$ table daily
BEGIN
DBMS_SCHEDULER.create_job (
job_name => 'JOB_PURGE_AUDIT_RECORDS',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP(DBMS_AUDIT_MGMT.AUDIT_TRAIL_AUD_STD, TRUNC(SYSTIMESTAMP)-30); END;',
start_date => SYSTIMESTAMP,
repeat_interval => 'freq=daily; byhour=0; byminute=0; bysecond=0;',
end_date => NULL,
enabled => TRUE,
comments => 'Update last_archive_timestamp');
END;
/

-- Select the scheduler job
select LAST_START_DATE,LAST_RUN_DURATION,NEXT_RUN_DATE from dba_scheduler_jobs where job_name= ’JOB_PURGE_AUDIT_RECORDS’;

Purge the Audit records with truncate or DBMS_AUDIT_MGMT package (2024)
Top Articles
Inventory Excel Formulas You Should Know
Dragon Age: 10 Best Dragons
Dairy Queen Lobby Hours
4-Hour Private ATV Riding Experience in Adirondacks 2024 on Cool Destinations
Wells Fargo Careers Log In
Walgreens Alma School And Dynamite
Waive Upgrade Fee
Comenity Credit Card Guide 2024: Things To Know And Alternatives
Gfs Rivergate
Kaomoji Border
Walmart Windshield Wiper Blades
Bad Moms 123Movies
Craiglist Tulsa Ok
Jinx Chapter 24: Release Date, Spoilers & Where To Read - OtakuKart
라이키 유출
Urban Airship Expands its Mobile Platform to Transform Customer Communications
Vintage Stock Edmond Ok
Nearest Walgreens Or Cvs Near Me
Jeffers Funeral Home Obituaries Greeneville Tennessee
Red8 Data Entry Job
Bocca Richboro
Villano Antillano Desnuda
The Goonies Showtimes Near Marcus Rosemount Cinema
HP PARTSURFER - spare part search portal
Page 2383 – Christianity Today
Indiana Jones 5 Showtimes Near Jamaica Multiplex Cinemas
Kokomo Mugshots Busted
Forager How-to Get Archaeology Items - Dino Egg, Anchor, Fossil, Frozen Relic, Frozen Squid, Kapala, Lava Eel, and More!
Synchrony Manage Account
Facebook Marketplace Marrero La
Studentvue Columbia Heights
Bitchinbubba Face
Merkantilismus – Staatslexikon
Weather Underground Bonita Springs
Deshuesadero El Pulpo
Wlds Obits
Craigslist Tulsa Ok Farm And Garden
Wrigley Rooftops Promo Code
Lbl A-Z
Go Bananas Wareham Ma
Discover Things To Do In Lubbock
Energy Management and Control System Expert (f/m/d) for Battery Storage Systems | StudySmarter - Talents
Sand Castle Parents Guide
Rocky Bfb Asset
Patricia And Aaron Toro
Marcal Paper Products - Nassau Paper Company Ltd. -
Gt500 Forums
Phumikhmer 2022
211475039
Honeybee: Classification, Morphology, Types, and Lifecycle
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 5999

Rating: 4.8 / 5 (48 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.