Oracle User Locked(Timed)

Why Oracle user get locked(timed) ? I had change profile : PASSWORD_LIFE_TIME, PASSWORD_LOCK_TIME, PASSWORD_GRACE_TIME to UNLIMITED, but it doesn’t work.

Then I run audit trail :

  1. alter system set audit_trail=db scope=spfile; (then restart db)
  2. audit connect whenever not successful;
  3. monitoring via this query : 

    SELECT *
    FROM dba_audit_session
    WHERE action_name = ‘LOGON’ AND returncode > 0
    ORDER BY timestamp DESC;

  4. then login fail and then locked because the user password case-sensitive, so I run : alter system set sec_case_sensitive_logon=false;
  5. done ^_^

 

Oracle RMAN Backup Script In Oracle Linux

This is rman.sh

ORACLE_SID=ITCAPPS; export ORACLE_SID
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
rman target / log=/home/oracle/rman.log << EOF
crosscheck backup;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
sql 'alter system switch logfile';
backup database format '/disk1/backup/full_%U.bkp';
delete noprompt obsolete;
EOF

And this is RMAN configuration,

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ITCAPPS are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/disk1/backup/controlfile_autobackup_%F.bkp';
CONFIGURE DEVICE TYPE DISK PARALLELISM 4 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_ITCAPPS.f'; # default

Oracle Database in Oracle Linux Cannot Start / Open

Today I mess around with the Oracle database that can not start and open. I get some error messages from various places such as alert.log, sqlplus, rman.

These errors are,

ORA-03110: end-of-file on communication channel
ORA-03135: connection lost contact
ORA-00845: MEMORY_TARGET not supported on this system
ORA-16038: log 3 sequence# 400 cannot be archived
ORA-19502: write error on file "", block number  (block size=)
ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/ITCAPPS/redo03.log'
ORA-19816: WARNING: Files may exist in db_recovery_file_dest that are not known to database.
ORA-00257: archiver error. Connect internal only, until freed.

I have do this step :
1. replace the  current spfile with the old one
2. startup with pfile
3. restore and recover database using rman

But that no help at all.

And the real solution is to enlarge the capacity of the folder where the archivelog is

Cancel Oracle Trigger to Execute The Commands

Hi, I want to cancel the trigger of a table that does not work if the logic condition is not met. So as if I want the trigger to rollback (for example = cancel delete in before-delete trigger). At first, the trigger like this :

CREATE OR REPLACE TRIGGER MIS.TRIG01_TABLE_A
BEFORE DELETE
ON PANDAZEN.TABLE_A
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
INSERT INTO PANDAZEN.TABLE_B
SELECT * FROM PANDAZEN.TABLE_A;
END;

The trick to achieve what I want, ie – cancel delete command in the before-delete trigger is to use the command

raise_application_error

So, now triggernya be like this :

CREATE OR REPLACE TRIGGER MIS.TRIG01_TABLE_A
BEFORE DELETE
ON PANDAZEN.TABLE_A
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
IF (:OLD.TABLE_A_VALUE = ‘OLD’) THEN
RAISE_APPLICATION_ERROR (-20000, ‘CANCEL DELETE’);
END IF;

INSERT INTO PANDAZEN.TABLE_B
SELECT * FROM PANDAZEN.TABLE_A;
END;

Oracle Predefined PL/SQL Exceptions

Exception ORA Error SQLCODE Raise When …
ACCESS_INTO_NULL 06530 -6530 A program attempts to assign values to the attributes of an uninitialized object
CASE_NOT_FOUND 06592 -6592 None of the choices in the WHEN clauses of a CASE statement is selected, and there is no ELSE clause.
COLLECTION_IS_NULL 06531 -6531 A program attempts to apply collection methods other than EXISTS to an uninitialized nested table or varray, or the program attempts to assign values to the elements of an uninitialized nested table or varray.
CURSOR_ALREADY_OPEN 06511 -6511 A program attempts to open an already open cursor. A cursor must be closed before it can be reopened. A cursor FOR loop automatically opens the cursor to which it refers, so your program cannot open that cursor inside the loop.
DUP_VAL_ON_INDEX 00001 -1 A program attempts to store duplicate values in a column that is constrained by a unique index.
INVALID_CURSOR 01001 -1001 A program attempts a cursor operation that is not allowed, such as closing an unopened cursor.
INVALID_NUMBER 01722 -1722 n a SQL statement, the conversion of a character string into a number fails because the string does not represent a valid number. (In procedural statements, VALUE_ERROR is raised.) This exception is also raised when the LIMIT-clause expression in a bulk FETCH statement does not evaluate to a positive number.
LOGIN_DENIED 01017 -1017 A program attempts to log on to Oracle with an invalid username or password.
NO_DATA_FOUND 01403 +100 A SELECT INTO statement returns no rows, or your program references a deleted element in a nested table or an uninitialized element in an index-by table.Because this exception is used internally by some SQL functions to signal completion, you should not rely on this exception being propagated if you raise it within a function that is called as part of a query.
NOT_LOGGED_ON 01012 -1012 A program issues a database call without being connected to Oracle.
PROGRAM_ERROR 06501 -6501 PL/SQL has an internal problem.
ROWTYPE_MISMATCH 06504 -6504 The host cursor variable and PL/SQL cursor variable involved in an assignment have incompatible return types. When an open host cursor variable is passed to a stored subprogram, the return types of the actual and formal parameters must be compatible.
SELF_IS_NULL 30625 -30625 A program attempts to call a MEMBER method, but the instance of the object type has not been initialized. The built-in parameter SELF points to the object, and is always the first parameter passed to a MEMBER method.
STORAGE_ERROR 06500 -6500 PL/SQL runs out of memory or memory has been corrupted.
SUBSCRIPT_BEYOND_COUNT 06533 -6533 A program references a nested table or varray element using an index number larger than the number of elements in the collection.
SUBSCRIPT_OUTSIDE_LIMIT 06532 -6532 A program references a nested table or varray element using an index number (-1 for example) that is outside the legal range.
SYS_INVALID_ROWID 01410 -1410 The conversion of a character string into a universal rowid fails because the character string does not represent a valid rowid.
TIMEOUT_ON_RESOURCE 00051 -51 A time out occurs while Oracle is waiting for a resource.
TOO_MANY_ROWS 01422 -1422 A SELECT INTO statement returns more than one row.
VALUE_ERROR 06502 -6502 An arithmetic, conversion, truncation, or size-constraint error occurs. For example, when your program selects a column value into a character variable, if the value is longer than the declared length of the variable, PL/SQL aborts the assignment and raises VALUE_ERROR. In procedural statements, VALUE_ERROR is raised if the conversion of a character string into a number fails. (In SQL statements, INVALID_NUMBER is raised.)
ZERO_DIVIDE 01476 -1476 A program attempts to divide a number by zero.

source : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/errors.htm

Undo Retention

To set the minimum undo retention period:

  • Set UNDO_RETENTION in the initialization parameter file.
    UNDO_RETENTION = 1800
  • Using the ALTER SYSTEM statement to change UNDO_RETENTION immediately.
    ALTER SYSTEM SET UNDO_RETENTION = 1800;

Be careful, once you change UNDO_RETENTION parameter, the effect will be immediately and it effected undo tablespace, so make sure your disk have enough space disk. If disk doesn’t enough, your client / application connection to database server will be unstable.

staticports.ini

When installing Oracle Application Server 10g Release 2 (10.1.2.0.2) you can control the ports configuration using staticports.ini.

A sample default staticports.ini show below,

# staticports.ini - default
# J2EE and HTTP Server
Oracle HTTP Server port = 7777
Oracle HTTP Server Listen port = 7777
Oracle HTTP Server SSL port = 4443
Oracle HTTP Server Listen (SSL) port = 4443
Oracle HTTP Server Diagnostic port = 7200
Java Object Cache port = 7000
DCM Discovery port = 7100
Oracle Notification Server Request port = 6003
Oracle Notification Server Local port = 6101
Oracle Notification Server Remote port = 6200
Application Server Control port = 18100
Application Server Control RMI port = 18140
Oracle Management Agent port = 18120
Log Loader port = 44000
ASG port = 7890

# Infrastructure
Oracle Internet Directory port = 13060
Oracle Internet Directory (SSL) port = 13130
#Oracle Certificate Authority SSL Server Authentication port = port_num
#Oracle Certificate Authority SSL Mutual Authentication port = port_num

Enterprise Manager Console HTTP Port (orcl) = 5500
Enterprise Manager Agent Port (orcl) = 1830

# OracleAS Metadata Repository: Installation Port = 1521

Select Top-N in Oracle

Use DENSE_RANK to select top-n of a table in Oracle

SELECT *
FROM (SELECT EMPLOYEE_ID, FIRST_NAME, SALARY,
DENSE_RANK () OVER (ORDER BY SALARY DESC) TOPRANK
FROM HR.EMPLOYEES)
WHERE TOPRANK <= 3

Check duplicate index

Rule for good index :

If 2 indexes ( I1 and I2 ) exist for a table and
   the number of columns in Index I1 is less or equal to the number of column
in index I2 and
   index I1 has the same columns in the same order as leading columns of index
I2
Then
   If index I1 is UNIQUE then
      If index I2 is used to support Foregh Key or for Index Overload then
         Do Nothing
      Else
         Index I2 can be DROPPED
      End If
   Else
      Index I1 can be DROPPED
   End If
End If

To check duplicate index, use this query :

1. from orafaq

SELECT   /*+ RULE */
TAB_OWNER.NAME OWNER, T.NAME TABLE_NAME,
O1.NAME
|| '('
|| DECODE (BITAND (I1.PROPERTY, 1), 0, 'N', 1, 'U', '*')
|| ')' INCLUDED_INDEX_NAME,
O2.NAME
|| '('
|| DECODE (BITAND (I2.PROPERTY, 1), 0, 'N', 1, 'U', '*')
|| ')' INCLUDING_INDEX_NAME
FROM SYS.USER$ TAB_OWNER,
SYS.OBJ$ T,
SYS.IND$ I1,
SYS.OBJ$ O1,
SYS.IND$ I2,
SYS.OBJ$ O2
WHERE I1.BO# = I2.BO#
AND I1.OBJ#  I2.OBJ#
AND I2.COLS >= I1.COLS
AND I1.COLS > 0
AND I1.COLS =
(SELECT /*+ ORDERED */
COUNT (1)
FROM SYS.ICOL$ CC1, SYS.ICOL$ CC2
WHERE CC2.OBJ# = I2.OBJ#
AND CC1.OBJ# = I1.OBJ#
AND CC2.POS# = CC1.POS#
AND CC2.COL# = CC1.COL#)
AND I1.OBJ# = O1.OBJ#
AND I2.OBJ# = O2.OBJ#
AND T.OBJ# = I1.BO#
AND T.OWNER# = TAB_OWNER.USER#
AND TAB_OWNER.NAME LIKE '%'
ORDER BY 1, 2

2. from dba-oracle

SELECT   /*+ RULE */
A.TABLE_OWNER, A.TABLE_NAME, A.INDEX_OWNER, A.INDEX_NAME,
COLUMN_NAME_LIST, COLUMN_NAME_LIST_DUP, DUP DUPLICATE_INDEXES,
I.UNIQUENESS, I.PARTITIONED, I.LEAF_BLOCKS, I.DISTINCT_KEYS,
I.NUM_ROWS, I.CLUSTERING_FACTOR
FROM (SELECT TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME,
COLUMN_NAME_LIST_DUP, DUP,
MAX (DUP) OVER (PARTITION BY TABLE_OWNER, TABLE_NAME, INDEX_NAME)
DUP_MX
FROM (SELECT     TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME,
SUBSTR
(SYS_CONNECT_BY_PATH (COLUMN_NAME, ','),
2
) COLUMN_NAME_LIST_DUP,
DUP
FROM (SELECT INDEX_OWNER, INDEX_NAME, TABLE_OWNER,
TABLE_NAME, COLUMN_NAME,
COUNT (1) OVER (PARTITION BY INDEX_OWNER, INDEX_NAME)
CNT,
ROW_NUMBER () OVER (PARTITION BY INDEX_OWNER, INDEX_NAME ORDER BY COLUMN_POSITION)
AS SEQ,
COUNT (1) OVER (PARTITION BY TABLE_OWNER, TABLE_NAME, COLUMN_NAME, COLUMN_POSITION)
AS DUP
FROM SYS.DBA_IND_COLUMNS
WHERE INDEX_OWNER NOT IN
('SYS', 'SYSTEM', 'DLOBAUGH'))
WHERE DUP != 1
START WITH SEQ = 1
CONNECT BY PRIOR SEQ + 1 = SEQ
AND PRIOR INDEX_OWNER = INDEX_OWNER
AND PRIOR INDEX_NAME = INDEX_NAME)) A,
(SELECT     TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME,
SUBSTR
(SYS_CONNECT_BY_PATH (COLUMN_NAME, ','),
2
) COLUMN_NAME_LIST
FROM (SELECT INDEX_OWNER, INDEX_NAME, TABLE_OWNER, TABLE_NAME,
COLUMN_NAME,
COUNT (1) OVER (PARTITION BY INDEX_OWNER, INDEX_NAME)
CNT,
ROW_NUMBER () OVER (PARTITION BY INDEX_OWNER, INDEX_NAME ORDER BY COLUMN_POSITION)
AS SEQ
FROM SYS.DBA_IND_COLUMNS
WHERE INDEX_OWNER NOT IN ('SYS', 'SYSTEM'))
WHERE SEQ = CNT
START WITH SEQ = 1
CONNECT BY PRIOR SEQ + 1 = SEQ
AND PRIOR INDEX_OWNER = INDEX_OWNER
AND PRIOR INDEX_NAME = INDEX_NAME) B,
DBA_INDEXES I
WHERE A.DUP = A.DUP_MX
AND A.INDEX_OWNER = B.INDEX_OWNER
AND A.INDEX_NAME = B.INDEX_NAME
AND A.INDEX_OWNER = I.OWNER
AND A.INDEX_NAME = I.INDEX_NAME
ORDER BY A.TABLE_OWNER, A.TABLE_NAME, COLUMN_NAME_LIST_DUP;

Reset ias_admin password

If you still remember what your last ias_admin password then to change it, you can use emct, eg:

emctl set password <old_password> <new_password>

or login to Oracle Enterprise Manager <version>- Application Server Control then click on Preferences on top right to open “Change Password” screen.

If you have forgot what the password then you must read this,

ias_admin password stored in XML file (JAZN-XML –  Java AuthoriZatioN).  First, backup the file, located in $ORACLE_HOME/sysman/j2ee/config/jazn-data.xml. Open and find

<user>

<name>ias_admin</name>

<credentials>{903}DZ4tCvKMR8blcIAx1vZsz7qL4RIhSTbEGU3Q20WILfF=</credentials>

</user>

then update it to

<user>

<name>ias_admin</name>

<credentials>!adminpass</credentials>

</user>

or you can remove it and then run %ORACLE_HOME%\bin\emctl set password reset <new_password> , restart computer.

Note : Exclamation Mark in front of password means that password is stored in plain text, so the current password is “adminpass”

Select Last Row in Oracle

SELECT *
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID = (SELECT MAX (EMPLOYEE_ID)
FROM HR.EMPLOYEES);

Select Row X to Y in Oracle

the fastest query,

SELECT *
FROM (SELECT A.*, ROWNUM RN
FROM (SELECT *
FROM HR.EMPLOYEES
ORDER BY EMPLOYEE_ID) A
WHERE ROWNUM <= :Y)
WHERE RN >= :X;

another query,
1.SELECT *
FROM (SELECT EMP.*, ROWNUM RN
FROM HR.EMPLOYEES EMP
WHERE ROWNUM < :Y + 1
ORDER BY EMPLOYEE_ID)
WHERE RN BETWEEN :X AND :Y;

2.SELECT *
FROM HR.EMPLOYEES
WHERE EMPLOYEE_ID IN (SELECT EMPLOYEE_ID
FROM HR.EMPLOYEES
GROUP BY ROWNUM, EMPLOYEE_ID
HAVING ROWNUM BETWEEN :X AND :Y)
ORDER BY EMPLOYEE_ID;

3.SELECT *
FROM HR.EMPLOYEES
WHERE ROWID IN (SELECT ROWID
FROM (SELECT * FROM HR.EMPLOYEES ORDER BY EMPLOYEE_ID)
WHERE ROWNUM <= :Y
MINUS
SELECT ROWID
FROM (SELECT * FROM HR.EMPLOYEES ORDER BY EMPLOYEE_ID)
WHERE ROWNUM < :X)

Can’t initialize OCI. Error -1

It appears when connect to Oracle and make login fail. The solution to try is to check where is ORACLE HOME and TNS ADMIN location

OCI.dll could not be loaded in PHP-Apache

I’ve installed XAMP 1.6.6a  and running of apache 2.2.8 and PHP 5.2.5 versions. I also install oracle instant client 10.2.0.1.0 so i want to connect to oracle via php using oci.  I got this message when i start apache

Apache.exe
This application has failed to start because oci.dll was not found. Re-installing the application may fix this problem.

I had try to set these variable

ORACLE_HOME, ORACLE_SID, NLS_LANG

and uncomment the following lines in php.ini file

;extension=php_oracle.dll
;extension=php_oci8.dll;
also
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll

but error message would not dissapear

Then I copy oci.dll to folder apache\bin and restart apache, it works fine now. But make sure your oci.dll from Oracle 10, older version will not work.

You can test it using php.exe -m, if you can’t find any error or warning and you see oci8 in list then congratulations!! you succeed to setup oracle extension.

If another error message, such as

The procedure entry point OCIStmtPrepare2 could not be located in the dynamic link library OCI.dll,

then copy oci.dll to php directory and restart apache and test again

REP-0118: Unable to create a temporary file

Almost the same problem i have found when execute query using form applet when i got this message FRM-41838: Unable to open temporary record buffer file %s.  And then i got this message when i run report. Here the message,

REP-0118 Unable to create a temporary file

The solution i found that maybe help for anyone who face the same problem,

– Check user variables
TEMP and TMP refers to directory that exists, if not exists then you must edit the value

– check free space on the disk, it must be enough space to create temporary file

– delete file in temporary directory, maybe, it cannot be modified because read only or already exists

– check registry setting using REGEDIT, locate variable REPORTS_TMP underkey hkey_local_machine/software/oracle/<oracle home>
make sure the value of the variable refers to exist directory

FRM-41838: Unable to open temporary record buffer file %s.

Today, I got this error message when execute query in form applet

FRM-41838 Unable to open temporary record buffer file
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\1\s3n4.1
ORA-01403: no data found

The result of my search about this message explain this,

FRM-41838: Unable to open temporary record buffer file %s.
Cause : Unable to open file used as temporary record buffer.
Action: Verify that the file system or directory in which the file resides exists and that you have permissions to read and write to it.

The solution that maybe help,

The problem i found in opmn.xml.
So, search <variable id=”TMP” value=”C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\1″/>
there is a reference to temp directory which doesn’t exists, edit the value to a valid directory.

[- -]

Shrink Table

To shrink an object

ALTER TABLE employees SHRINK SPACE [CASCADE]

To shrink a LOB (must be issued separately since SHRINK SPACE CASCADE does not cascade to LOB)

ALTER TABLE employees MODIFY LOB(resume) (SHRINK SPACE)

Shrink the overflow segment of an Index Organized Table (IOT)

ALTER TABLE employees OVERFLOW SHRINK SPACE

Use DBMS_SCHEDULER to replace DBMS_JOB

DBMS_JOB has been around forever, and now it is deprecated. Although DBMS_JOB still exists in 10g and 11g, but only for backward compatibility. No new features are being added to dbms_job and you will likely quickly run into its limitations. Oracle recommends the use of DBMS_SCHEDULER in releases 10g and up. DBMS_SCHEDULER is a much more robust package and fully-featured than DBMS_JOB. To use the DBMS_SCHEDULER package a user must be granted the CREATE JOB privilege.

DBMS_SCHEDULERincludes the following features that DBMS_JOB does not have :

  • logging of job runs (job history)
  • simple but powerful scheduling syntax (similar to but more powerful than cron syntax)
  • running of jobs outside of the database on the operating system
  • resource management between different classes of jobs
  • use of job arguments including passing of objects into stored procedures
  • privilege-based security model for jobs
  • naming of jobs and comments in jobs
  • stored, reusable schedules

Features in releases after 10g Release 1 include :

  • dependencies between job units (10gR2 and up)
  • scheduling based on financial calendars and fiscal quarters (10gR2 and up)
  • event based jobs which run when an event is received (10gR2 and up)
  • running of jobs on remote machines (11gR1 and up)
  • e-mail notifications on job events of interest (10gR2 and up)
  • starting a job based on arrival of a file (10gR2 and up)

Here simple comparison for the codes :

  • Old using DBMS_JOB scheduler.VARIABLE l_job NUMBER;
    BEGIN
    DBMS_JOB.submit (
    job => :l_job,
    what => ‘BEGIN NULL; /* code to execute*/ END;’,
    next_date => SYSDATE,
    interval => ‘SYSDATE + 1 /* 1 Day */’);COMMIT;
    END;
    /
    PRINT l_job
  • New with DBMS_SCHEDULER scheduler.BEGIN
    DBMS_SCHEDULER.create_job (
    job_name => ‘dummy_job’,
    job_type => ‘PLSQL_BLOCK’,
    job_action => ‘BEGIN NULL; /* code to execute */ END;’,
    start_date => SYSTIMESTAMP,
    repeat_interval => ‘SYSTIMESTAMP + 1 /* 1 Day */’);
    END;
    /

After replace DBMS_JOB with DBMS_SCHEDULER for all jobs successful, the job_queue_processes parameter can now be set to zero.

alter system set job_queue_processes=0;

There is also a forum dedicated to questions about dbms_scheduler here : http://forums.oracle.com/forums/forum.jspa?forumID=193

How to clear Oracle Enterprise Manager’s Alert

first, check this

– SELECT * FROM SYSMAN.MGMT_CURRENT_SEVERITY ORDER BY COLLECTION_TIMESTAMP

if the result is that you want to delete then go with this sql,

– DELETE SYSMAN.MGMT_CURRENT_SEVERITY

^_^

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;