History startup & shutdown DB


1. create table to store history startup – shutdown DB

CREATE TABLE WI.TMP_DATABASE_ACTIVITY
(
USER_NAME      VARCHAR2(20 BYTE),
USER_TIME        DATE,
DESCRIPTION  VARCHAR2(30 BYTE)
)
TABLESPACE TBLSPC_01;

2. create trigger after startup

CREATE OR REPLACE TRIGGER WI.TRIG_STARTUP
AFTER STARTUP ON DATABASE
BEGIN
INSERT INTO TMP_DATABASE_ACTIVITY
VALUES (USER, SYSDATE, ‘STARTUP’);
END;
/

3. create trigger before shutdown

CREATE OR REPLACE TRIGGER WI.TRIG_SHUTDOWN
BEFORE SHUTDOWN ON DATABASE
BEGIN
INSERT INTO TMP_DATABASE_ACTIVITY
VALUES (USER, SYSDATE, ‘SHUTDOWN’);
END;
/

4. to see the history

SELECT * FROM TMP_DATABASE_ACTIVITY ORDER BY USER_TIME;

Advertisements

One Response

  1. Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: