Wednesday, April 23, 2014

Simple way to find the DB STARTUP and SHUTDOWN with Triggers

Simple way to check DB STARTUP  and SHUTDOWN time 

Whenever Instance was started or shutdown, These information not stored in Oracle Views/Tables. In this case used to refer Alert Log file when it was bounced.
Instead of reviewing we can create a table, along with this have to create two tirggers, One trigger will be activated once startup time and another trigger will be activated on shutdown. at the same time whenever trigger activated table Will be updated. So that we can view from Table all the history after creating the table with trigger.



STEP1- 

CREATE TABLE CKPT_DATABASE_ACTIVITY (NAME VARCHAR2(20 BYTE),TIME DATE,DESCRIPTION  VARCHAR2(30 BYTE)) TABLESPACE USERS;


STEP2- 

CREATE OR REPLACE TRIGGER CKPT_TRIG_STARTUP AFTER STARTUP ON DATABASE
 BEGIN
   INSERT INTO CKPT_DATABASE_ACTIVITY
   VALUES (USER, SYSDATE, 'STARTUP’);
 END;



STEP3- 

CREATE OR REPLACE TRIGGER CKPT_TRIG_SHUTDOWN BEFORE SHUTDOWN ON DATABASE
 BEGIN
   INSERT INTO CKPT_DATABASE_ACTIVITY
   VALUES (USER, SYSDATE, 'SHUTDOWN’);
 END;






No comments:

Post a Comment