Solved

Oracle Audit Table Maintenance

Posted on 2011-09-29
5
548 Views
Last Modified: 2012-05-12
Hello, we have implemented session level auditing of our Oracle payroll application and I'm wondering what is the best practice method to purge some of the data on a routine basis.  We are only required to keep a years worth of auditing records and as of right now we have about 2.5 in there.  The size of the audit data is actually growing larger than the actual data.  We would only be doing this purge once a year.

I'm a SQL Server person, so forgive my Oracle ignorance. :)
0
Comment
Question by:Roxanne25
  • 2
  • 2
5 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 125 total points
ID: 36816376
delete from your_audit_table where audit_timestamp < sysdate - 365
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 125 total points
ID: 36816389
if doing the delete in one step exceeds your rollback/undo limits  then try this...  adjust the 100000 to be as large as your undo will handle

note  I changed the sysdate-365 to the slightly more accurate    add_months(trunc(sysdate), -12)


BEGIN
        LOOP
            DELETE FROM your_audit_table
                  WHERE audit_timestamp < add_months(trunc(sysdate), -12) AND ROWNUM <= 100000;

            EXIT WHEN SQL%ROWCOUNT = 0;
            COMMIT;
        END LOOP;
END;
0
 

Author Comment

by:Roxanne25
ID: 36816741
Thanks guys that is quite helpful!

One more question though... you say your_audit_table as the table name but the tables I wish to prune are the system audit tables (SYS.AUD$).  Is it the same procedure for the system tables?  I was just concerned because I didn't know how permissions work around deleting information from system audit tables.
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 375 total points
ID: 36817054
The 10g docs say to just delete them:  Purging Audit Records from the Audit Trail

http://download.oracle.com/docs/cd/B19306_01/network.102/b14266/cfgaudit.htm

The 11g docs have other options:  Selecting an Audit Trail Purge Method

http://download.oracle.com/docs/cd/E11882_01/network.112/e16543/auditing.htm

0
 

Author Comment

by:Roxanne25
ID: 36817191
Great thank you!  That is helpful.... now just need to research this DBMS AUDIT MGMT :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question