100 scripts you should know as a DBA – Part 2

In this multipart dba scripts post , we are going to learn the important scripts that a DBA should know in order to do the day to day database administration. This post in entirely dedicated to aud$.

7. what is AUD$ in Oracle Database 11g

The data dictionary of every Oracle database has a table named SYS.AUD$, commonly referred to as the database audit trail. Depending on configuration choices, this table can reside in different schema, such as the traditional SYS schema in the SYSTEM tablespace.

The database audit trail is a single table named SYS.AUD$ in the SYS schema of each Oracle Database data dictionary. Several predefined views are provided to help you use the information in this table, such as DBA_AUDIT_TRAIL.

If you want to filter and analyze your audit data from AUD$ table you need to know ACTION# column.

There are several ACTION# types available and we can view the action types by querying

SELECT action, name FROM audit_actions ORDER BY 1;

Now, if we want to know the auditing information of logoff and logon, we can querying

select statement,timestamp#, userid, action#, returncode, logoff$time, comment$text from aud$ where action# in (100,101);

Few more useful queries you can try for

select statement ,timestamp#, userid, userhost,terminal, action#, returncode, logoff$time, comment$text from aud$ where action# in (100,101);

select a.timestamp#, a.userid, a.userhost,a.terminal, b.action,b.name, a.returncode, a.logoff$time, a.comment$text from aud$ a, audit_actions b
where a.action# = b.action ;

SELECT * FROM sys.aud$ a, audit_actions b WHERE a.action# = b.action AND TO_CHAR(TIMESTAMP#,’mm/yyyy’) = ’06/2018′ AND ROWNUM < 300 ORDER BY TIMESTAMP# DESC ;

select userid, terminal, spare1, substr(s1,1,instr(s1,’)’)-1) IP,
returncode, timestamp#
from (select A.*, substr(comment$text,instr(comment$text,’HOST=’)+5,100) s1
from aud$ a where action# in (100,101) )
order by IP;

Also read,

100 scripts you should know as a DBA – Part 1

Words from DBAPATH

Thank you for giving your valuable time to read the above information. I hope the content served your purpose in reaching out the blog.
Suggestions for improvement of the blog are highly appreciable. Please contact us for any information/suggestion/feedback.

If you want to be updated with all our articles

please follow us on Facebook Twitter
Please subscribe to our newsletter.