Database logon trigger : Database Level Trigger « Trigger « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE session_logon_statistics
  2  (user_logged VARCHAR2(30),
  3  start_time   DATE,
  4  end_time     DATE);

Table created.

SQL>
SQL>
SQL>
SQL> CREATE OR REPLACE TRIGGER logon_log_trigger
  2  AFTER LOGON
  3  ON DATABASE
  4  BEGIN
  5     INSERT INTO session_logon_statistics
  6     (user_logged, start_time)
  7     VALUES
  8     (USER, SYSDATE);
  9  END;
 10  /

Trigger created.

SQL>
SQL>
SQL>
SQL> SELECT user_logged,
  2         TO_CHAR(start_time, 'MM/DD/YYYY HH24:MI:SS') "START TIME",
  3         TO_CHAR(end_time, 'MM/DD/YYYY HH24:MI:SS') "END TIME"
  4  FROM   session_logon_statistics
  5  where   rownum < 50
  6  order by user_logged, start_time;

no rows selected

SQL>
SQL>
SQL> drop trigger logon_log_trigger;

Trigger dropped.

SQL>
SQL> drop table session_logon_statistics;

Table dropped.








28.14.Database Level Trigger
28.14.1.Database level trigger: AFTER STARTUP ON DATABASE
28.14.2.Database level trigger: BEFORE SHUTDOWN ON DATABASE
28.14.3.New Database triggers
28.14.4.Database logon trigger
28.14.5.Database logoff trigger
28.14.6.Save information about all errors in an after-servererror on database