简体   繁体   中英

How to audit system user logon , log off , database shutdown and startup (System Level Auditing)

How to enable a system or database level auditing in Oracle using SQL commands or rather in SQLPlus. Something to do with table views such as dba_audit_session. Overall I'm looking for SQL statement that audits the logon or attempts the logon of users and database startup time or shutdown.

To audit logins and logouts create LOGON and LOGOFF triggers that populate a regular history table. I myself prefer it. It's far simpler:


create table log_trail (name varchar2(30), time date, action varchar2(10));

create or replace trigger tr_logon
after logon on database
begin
insert into log_trail values (user, sysdate, 'LOGON');
commit;
end tr_logon;

create or replace trigger tr_logoff
before logoff on database
begin
insert into log_trail values (user, sysdate, 'LOGOFF');
commit;
end tr_logon;

Notes:

  • Beware of logon triggers. If they are not working, you may not logon to Oracle.

  • You must have the CREATE (ANY) TRIGGER and ADMINISTER DATABASE TRIGGER privileges to implement DATABASE triggers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM