Sunday, May 27, 2012

Alter table EMP shrink space


Alter table EMP shrink space
Thanks to Shilpa for asking and making me remind this too. I am trying to write a note on high water mark and shrink space command.

Whenever we create a table, at least one extent will be surely allocated to it. Even without a single row we can check minimum size of the table from dba_segments view. And immediately after creation of the table a high water mark is set to the first block of the first extent and which is gradually shift as we insert row in the table. So high water mark (HWM) is the maximum mark of extent table has ever reached.  “This extent allocation could be different if we set MINEXTENT with create table statement.”

Now let’s understand why it is (HWM) needed to be change. So assume we have a table which has 1000000 rows, so it must have allocated large number of extent and ultimately block with it. And assume we need to delete 50000 rows. But deletion rows from the table will not change the HWM from the table and there will be blank or better say empty formatted block with the table. And later again when there is insertion in the table, these empty block will be used.

But there are few insert statement that won’t use this empty block, these are serial or parallel insert statement, using direct=y with SQL LOADER and many more. I’m not sure for the exact reason behind this but may be because these statements won’t use SGA but rather will use PGA. And also temporary extent will be allocated in the default tablespace of session holding schema instead of temporary tablespace. This is also a reason for the error “ ORA-1652: unable to extend temp segment” even when you have large free space in temporary tablespace.

So this way gradually over a time we can have large number of empty blocks in the table and also high water mark at high level.

Thus to use this empty block and to get HWM to lower value we can use SHRINK SPACE command. But this will be only used when the tablespace holding the object will use Automatic Segment Space Management (ASSM) which is default from Oracle 10gR2 version.

With earlier versions we have “alter table table_name move” command which can be used for same purpose but that cause exclusive lock on the table. Although SHRINK SPACE also cause lock but at lower level, we will see this gradually.

So to use this command initially we need to allow ORACLE to change the ROWID (physical address of the rows of the table) by using command:

“alter table emp enable row movement”

Once done from this we can use SHRINK STATEMENT:

“alter table emp shrink space” .

Oracle SRHINK the space in two steps actually.

In the first steps, it moves the rows to the free blocks from the beginning.
And in second step it changes the ROWID. For changing the ROWID, ORACLE again needs EXCLUSIVE LOCK as in earlier versions but for very short period of time.

We have 3 version of SHRINK SPACE command available:

Alter table emp shrink space (this will complete both the steps on EMP table)

Alter table emp shrink space cascade (this will complete both the steps on all dependent objects like INDEXES)

Alter table emp shrink space compact ( now this command will only shift the rows to the empty block but it won’t change the HWM of the table).

Now to check when we need to perform this, we can use DBMS_SPACE package provided from ORACLE.

Please let me know if I have missed anything to this relevant topic.

Thanks. 

Thursday, May 17, 2012

goldengate starter


Architecture:

Extract: Captures changes and write in ST.
Source Trail file: Data Captured and written.
Data Pump: It is also extract, that read ST and send over the network.
Collector: Receive the ST and writes as RT (Remote Trail).
Delivery: To apply changes, started as background process by Replicate.
Manager: Manages all, default port is 7840.
Defgen: Use to generate the DDL.
Logdump: use to read the trail file.
Reverse: use to reverse the changes applied.
Veridata: Tool to compare source and target.
Director: Graphical tool to manage Golden-Gate.

Basic Replication:

Enable Supplement Loging:
alter database add supplemental log data;

Enable table level supplemental loging at table level:
ggsci> add trandata hr.employees

check from dba_log_group.

Disable trigger and cascade constraint at target system:

select ‘alter table’ || owner || ‘.’ || table_name || ‘disable constraint ‘ || constraint_name || ‘;’
from dba_constraint where delete_rule=’CASCADE’ and owner=’HR’;

select 'alter trigger '||owner||'.'||trigger_name|| ' disable ;'
from all_triggers where owner = '&SCHEMA';

Same query can be used to enable later !!!

NOTE: from version 11, SUPPRESSTRIGGER & DEFERREFCONST can be use with DBOPTION in Replicate parameter.

Info manager : information for manager
Start manager : to start manager

Adding extract:
ggsci> add extract ext, tranlog, begin now
ggsci> add extrail disdat/L1, extract ext, megabytes 100

stop extract ext
start extract ext
info extract ext
info extract ext, detail
stat extract ext

Data pump:

Passthru: to pass all without filtering
Rmthost: remote server name
Mgrport: manager port
Rmttrail: to specify two character name for remote trail file.

Replicate:
HANDLECOLLISION: to ignore if any difference between source and target tables.
ASSUMETARGETDEFS: when source and target are same.

Advanced Feature:

Report: Extract and Replicate DML runtime statistics.

SEND EXTRACT EXT REPORT
SEND EXTRACT REP REPORT

Reportcount: To count DML GG Proccsed since startup. Can be used in EXTRACT AND REPLICATE parameter.
Reportrollover: TO control report file over time.

DISCARDEFILE: To record discard.

Discardfile disdat/ext1.dsc append
Discardrollover at 12:00 ON SUNDAY.

Purging old trail file: (PURGEOLDEXTRACTS), can be used to purge old trail files..
PURGEOLDEXTRACTS DIRDAT/*, USECHECKPOINTS, MINKEEP 2 DAYS

Autostart: can be add in manager paremeter, for auto start.

Checkpoint Table: By default GG maintains checkpoint file on disk to tract the transaction processing. Best practice is to add checkpoint table in target database.

Add in global parameter:

CHECKPOINT TABLE GGES..CHKPT

ELSE

DBLOGIN USERID GGER PASSWORD PASSWORD
ADD CHECKPOINTTABLE
INFO CHECKPINTTABLE GGER.CHKPT

Adding DDL Replication:

Sql> grant execute on utl_transfer to gger;
Sql> @marker_setup.sql
Sql> @ddl_setup.sql
Sql> @role_setup.sql
Sql> @ddl_enable.sql

Add in local extract file:

DDL INCLUDE MAPPED

Monitoring Goldengate:

Info all
Info extract ext, detail ( check for sequence number, this should be current redo log group)

Checking LAG

>LAG EXTRACT EXT
>SEND EXTRACT EXT, GETLAG

>VIEW REPORT EXT
>STATS EXTRACT EXT

Wednesday, May 16, 2012

Checking the change in parameter happens in recent past


Checking the change in parameter happens in recent past . It check as per snap shots present.

col instance_number format 990 heading "SID"
col snap_id heading "Snap ID"
col name format a30 heading "Name"
col old_value format a30 heading "Old Value"
col new_value format a30 heading "New Value"
col diff format a15 heading "Numeric|Difference"
col instance_name new_value V_INSTANCE noprint
col snap_time format a20 heading "Snap Time"
set echo off feedback off timing off pagesize 100 linesize 180 trimout on trimspool on

select to_char(s.begin_interval_time, 'DD-MON-YYYY HH24:MI:SS') snap_time,p.instance_number,p.snap_id,p.name,p.old_value,p.new_value,
decode(trim(translate(p.new_value, '0123456789', '          ')),'',trim(to_char(to_number(p.new_value) - to_number(p.old_value),'999999999999990')),'') diff
from (select dbid,
instance_number,
snap_id,
parameter_name name,
lag(trim(lower(value))) over(partition by dbid, instance_number, parameter_name order by snap_id) old_value,
trim(lower(value)) new_value,
decode(nvl(lag(trim(lower(value)))
over(partition by dbid,
instance_number,
parameter_name order by snap_id),
trim(lower(value))),
trim(lower(value)),
'~NO~CHANGE~',
trim(lower(value))) diff
from dba_hist_parameter) p,
dba_hist_snapshot s
where s.begin_interval_time between trunc(sysdate - 31) and
sysdate
and p.dbid = s.dbid
and p.instance_number = s.instance_number
and p.snap_id = s.snap_id
and p.diff <> '~NO~CHANGE~'
order by snap_time, instance_number

SQL> col instance_number format 990 heading "SID"
SQL> col snap_id heading "Snap ID"
SQL> col name format a30 heading "Name"
col old_value format a30 heading "Old Value"
SQL> SQL> col new_value format a30 heading "New Value"
SQL> col diff format a15 heading "Numeric|Difference"
SQL> col instance_name new_value V_INSTANCE noprint
SQL> col snap_time format a20 heading "Snap Time"
SQL> set echo off feedback off timing off pagesize 100 linesize 180 trimout on trimspool on


SQL> l
  1  select to_char(s.begin_interval_time, 'DD-MON-YYYY HH24:MI:SS') snap_time,p.instance_number,p.snap_id,p.name,p.old_value,p.new_value,
  2  decode(trim(translate(p.new_value, '0123456789', '          ')),'',trim(to_char(to_number(p.new_value) - to_number(p.old_value),'999999999999990')),'') diff
  3  from (select dbid,
  4  instance_number,
  5  snap_id,
  6  parameter_name name,
  7  lag(trim(lower(value))) over(partition by dbid, instance_number, parameter_name order by snap_id) old_value,
  8  trim(lower(value)) new_value,
  9  decode(nvl(lag(trim(lower(value)))
10  over(partition by dbid,
11  instance_number,
12  parameter_name order by snap_id),
13  trim(lower(value))),
14  trim(lower(value)),
15  '~NO~CHANGE~',
16  trim(lower(value))) diff
17  from dba_hist_parameter) p,
18  dba_hist_snapshot s
19  where s.begin_interval_time between trunc(sysdate - 31) and
20  sysdate
21  and p.dbid = s.dbid
22  and p.instance_number = s.instance_number
23  and p.snap_id = s.snap_id
24  and p.diff <> '~NO~CHANGE~'
25* order by snap_time, instance_number
SQL> /

                                                                                                                                  Numeric
Snap Time             SID    Snap ID Name                           Old Value                      New Value                      Difference
-------------------- ---- ---------- ------------------------------ ------------------------------ ------------------------------ ---------------
08-APR-2012 08:00:16    1      22547 __db_cache_size                23622320128                    23488102400                    -134217728
08-APR-2012 08:00:16    1      22547 __shared_pool_size             2550136832                     2684354560                     134217728
08-APR-2012 10:00:42    1      22549 __shared_pool_size             2684354560                     2550136832                     -134217728
08-APR-2012 10:00:42    1      22549 __db_cache_size                23488102400                    23622320128                    134217728
09-APR-2012 12:00:12    1      22577 __db_cache_size                23622320128                    20937965568                    -2684354560
09-APR-2012 12:00:12    1      22577 shared_pool_size               0                              5234491392                     5234491392
09-APR-2012 12:00:12    1      22577 __shared_pool_size             2550136832                     5234491392                     2684354560

Monday, May 14, 2012

RMAN-06091: no channel allocated for maintenance (of an appropriate type)


When trying to delete obsolete backup, I get the error RMAN-06091. This is because no automatic channel is configured. Here is the solution.


RMAN> delete NOPROMPT FORCE obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           54609  04-MAY-12
  Backup Piece       54611  04-MAY-12          +DGFRA/TESTKING/autobackup/2012_05_04/s_782360264.1547.782360265
Backup Set           54700  04-MAY-12
  Backup Piece       54703  04-MAY-12          bk_1004_1_782395200
Backup Set           54765  04-MAY-12
  Backup Piece       54771  04-MAY-12          bk_1008_1_782396485
Backup Set           54992  04-MAY-12
  Backup Piece       55022  04-MAY-12          /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1017_P1_T782403372_20120504
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 05/14/2012 07:13:12
RMAN-06091: no channel allocated for maintenance (of an appropriate type)

RMAN> allocate channel for maintenance type disk;

allocated channel: ORA_MAINT_DISK_2
channel ORA_MAINT_DISK_2: SID=1265 instance=TESTKING1 device type=DISK

RMAN> delete obsolete device type disk;

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 7 days
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           54609  04-MAY-12
  Backup Piece       54611  04-MAY-12          +DGFRA/TESTKING/autobackup/2012_05_04/s_782360264.1547.782360265
Backup Set           54992  04-MAY-12
  Backup Piece       55022  04-MAY-12          /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1017_P1_T782403372_20120504

Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=+DGFRA/TESTKING/autobackup/2012_05_04/s_782360264.1547.782360265 RECID=984 STAMP=782360264
Deleted 1 objects

deleted backup piece
backup piece handle=/oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1017_P1_T782403372_20120504 RECID=992 STAMP=782403373
Deleted 1 objects


RMAN>
RMAN> delete expired backup;


List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
54859   54851   1   1   EXPIRED     DISK        /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1014_P1_T782403041_20120504
54860   54852   1   1   EXPIRED     DISK        /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1015_P1_T782403187_20120504
55021   54991   1   1   EXPIRED     DISK        /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1016_P1_T782403216_20120504
55260   55255   1   1   EXPIRED     DISK        /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1024_P1_T782650481_20120507
55261   55256   1   1   EXPIRED     DISK        /oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1025_P1_T782650643_20120507

Do you really want to delete the above objects (enter YES or NO)? YES
deleted backup piece
backup piece handle=/oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1014_P1_T782403041_20120504 RECID=989 STAMP=782403042
deleted backup piece
backup piece handle=/oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1015_P1_T782403187_20120504 RECID=990 STAMP=782403188
deleted backup piece
backup piece handle=/oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1016_P1_T782403216_20120504 RECID=991 STAMP=782403218
deleted backup piece
backup piece handle=/oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1024_P1_T782650481_20120507 RECID=995 STAMP=782650488
deleted backup piece
backup piece handle=/oravl01/oracle/11.1.0.7/dbs/backup_TESTKING_set1025_P1_T782650643_20120507 RECID=996 STAMP=782650643
Deleted 5 EXPIRED objects


RMAN>


For tape based backup,


RMAN> allocate channel for maintenance device type 'sbt_tape' parms. 


change your tape parameter. Also see ID: 567555.1 

Monday, May 7, 2012

Oracle optimizer


Many times we need to gather statistics to let optimizer get best plan for accessing the rows. With earlier versions that was done by ANALYAZE command but for now Oracle provide the DBMS_STATS pl/sql package as a preferred way to gather statistics.

Also, from Oracle 10G Oracle does automatic job for gathering statistics for the tables needed. But which process does this job, how to stop, start this process and when oracle knows which table statistics need to be gathered.

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

SQL> select client_name,status from Dba_Autotask_Client;

CLIENT_NAME                                                      STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection                                  ENABLED
auto space advisor                                               ENABLED
sql tuning advisor                                               ENABLED

SQL>

So, above are the automatic jobs and  ‘auto optimizer stats collection’  is the one which is responsible for gathering statistics on the needed tables.

Statistics on a table are considered to be stale when more than 10% of the rows are changed (DML’s). Oracle does this monitoring from the *_tab_modification view. Before 11g, this stale percent was fixed at 10% but now we can even change this percent.

SQL> select dbms_stats.get_prefs ('ESTIMATE_PERCENT','JAY', 'TEST') ESTIMATE_PERCENT from dual;

ESTIMATE_PERCENT
--------------------------------------------------------------------------------
DBMS_STATS.AUTO_SAMPLE_SIZE

So it is default value i.e. 10%.  Now changing this to 15%.

SQL> exec DBMS_STATS.SET_TABLE_PREFS('JAY', 'EMP','ESTIMATE_PERCENT','15');

PL/SQL procedure successfully completed.

SQL> select dbms_stats.get_prefs ('ESTIMATE_PERCENT','JAY', 'EMP') ESTIMATE_PERCENT from dual;

ESTIMATE_PERCENT
--------------------------------------------------------------------------------
15

So we have changed the stale percent for EMP table under JAY schema. Now lets work to stop this automated job. This can be done by dbms_auto_tas_admin procedure. 

SQL> begin
  2  dbms_auto_task_admin.disable (
  3  client_name => 'auto optimizer stats collection',
  4  operation => NULL,
  5  window_name => NULL);
  6  end;
  7  /

PL/SQL procedure successfully completed.

Lets check,

SQL> select client_name,status from Dba_Autotask_Client;

CLIENT_NAME                                                      STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection                                  DISABLED
auto space advisor                                               ENABLED
sql tuning advisor                                               ENABLED

Now my auto optimizer job is stopped. Let's again start using same package. 

SQL> begin
  2  dbms_auto_task_admin.enable (
  3  client_name => 'auto optimizer stats collection',
  4  operation => NULL,
  5  window_name => NULL);
  6  end;
  7  /

PL/SQL procedure successfully completed.

SQL> select client_name,status from Dba_Autotask_Client;

CLIENT_NAME                                                      STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection                                  ENABLED
auto space advisor                                               ENABLED
sql tuning advisor                                               ENABLED

SQL>

Thanks.

Thursday, May 3, 2012

DBA_TAB_MODIFICATION


DBA_TAB_MODIFICATION view does not immediately populated after the modification happen on the table. FLUSH_DATABASE_MONITORING_INFO procedure in the DBMS_STATS  package can be used to populate until recent information. Also to add, ANALYZE_ANY system privilege is required to run this procedure.

Below is the test study.

SQL> create table test29 as select * from test23;

Table created.

SQL> select table_name, inserts, updates, deletes from user_tab_modifications where table_name='TEST29';

no rows selected

SQL> select * from test29;

         X
----------
    100000
9999999999

SQL> insert into test29 values (2);

1 row created.

SQL> select table_name, inserts, updates, deletes from user_tab_modifications where table_name='TEST29';

no rows selected

SQL> exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO;

PL/SQL procedure successfully completed.

SQL> select table_name, inserts, updates, deletes from user_tab_modifications where table_name='TEST29';

TABLE_NAME                        INSERTS    UPDATES    DELETES
------------------------------ ---------- ---------- ----------
TEST29                                  1          0          0

SQL> select * from test29;

         X
----------
    100000
9999999999
         2

SQL> delete from test29 where x=2;

1 row deleted.

SQL> select table_name, inserts, updates, deletes from user_tab_modifications where table_name='TEST29';

TABLE_NAME                        INSERTS    UPDATES    DELETES
------------------------------ ---------- ---------- ----------
TEST29                                  1          0          0

SQL> commit;

Commit complete.

SQL> select table_name, inserts, updates, deletes from user_tab_modifications where table_name='TEST29';

TABLE_NAME                        INSERTS    UPDATES    DELETES
------------------------------ ---------- ---------- ----------
TEST29                                  1          0          0

SQL> exec dbms_stats.FLUSH_DATABASE_MONITORING_INFO;

PL/SQL procedure successfully completed.

SQL> select table_name, inserts, updates, deletes from user_tab_modifications where table_name='TEST29';

TABLE_NAME                        INSERTS    UPDATES    DELETES
------------------------------ ---------- ---------- ----------
TEST29                                  1          0          1

SQL>

x$dbgalertext


SQL> conn / as sysdba
Connected.
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

SQL> create view v$alert_log as select * from x$dbgalertext;

View created.

SQL> create public synonym v$alert_log for v$alert_log;

Synonym created.

SQL> grant select on v$alert_log to jay;

Grant succeeded.

SQL> conn jay/magic
Connected.
SQL> desc v$alert_log
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ADDR                                               RAW(8)
 INDX                                               NUMBER
 INST_ID                                            NUMBER
 ORIGINATING_TIMESTAMP                              TIMESTAMP(3) WITH TIME ZONE
 NORMALIZED_TIMESTAMP                               TIMESTAMP(3) WITH TIME ZONE
 ORGANIZATION_ID                                    VARCHAR2(64)
 COMPONENT_ID                                       VARCHAR2(64)
 HOST_ID                                            VARCHAR2(64)
 HOST_ADDRESS                                       VARCHAR2(46)
 MESSAGE_TYPE                                       NUMBER
 MESSAGE_LEVEL                                      NUMBER
 MESSAGE_ID                                         VARCHAR2(64)
 MESSAGE_GROUP                                      VARCHAR2(64)
 CLIENT_ID                                          VARCHAR2(64)
 MODULE_ID                                          VARCHAR2(64)
 PROCESS_ID                                         VARCHAR2(32)
 THREAD_ID                                          VARCHAR2(64)
 USER_ID                                            VARCHAR2(64)
 INSTANCE_ID                                        VARCHAR2(64)
 DETAILED_LOCATION                                  VARCHAR2(160)
 PROBLEM_KEY                                        VARCHAR2(64)
 UPSTREAM_COMP_ID                                   VARCHAR2(100)
 DOWNSTREAM_COMP_ID                                 VARCHAR2(100)
 EXECUTION_CONTEXT_ID                               VARCHAR2(100)
 EXECUTION_CONTEXT_SEQUENCE                         NUMBER
 ERROR_INSTANCE_ID                                  NUMBER
 ERROR_INSTANCE_SEQUENCE                            NUMBER
 VERSION                                            NUMBER
 MESSAGE_TEXT                                       VARCHAR2(2048)
 MESSAGE_ARGUMENTS                                  VARCHAR2(128)
 SUPPLEMENTAL_ATTRIBUTES                            VARCHAR2(128)
 SUPPLEMENTAL_DETAILS                               VARCHAR2(128)
 PARTITION                                          NUMBER
 RECORD_ID                                          NUMBER

SQL> set lin 180
SQL> col ORIGINATING_TIMESTAMP format A20
SQL> col MESSAGE_TEXT format A90
SQL> select MESSAGE_TEXT from v$alert_log WHERE MESSAGE_TEXT LIKE 'ORA-%' ;

MESSAGE_TEXT
------------------------------------------------------------------------------------------
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
ORA-1589 signalled during: alter database open...
ORA-16038: log 1 sequence# 169 cannot be archived
ORA-19502: write error on file "", block number  (block size=)
ORA-00312: online log 1 thread 1:


Some more that can be used to read alert log:

select DISTINCT ORIGINATING_TIMESTAMP,MESSAGE_TEXT from v$alert_log WHERE MESSAGE_TEXT LIKE 'ORA-%' or MESSAGE_TEXT LIKE '%Fatal%' AND ORIGINATING_TIMESTAMP > SYSDATE-4; 

select rownum “line”, message_text “error” from v$alert_log where originating_timestamp > (sysdate – 5/1440) and message_text like ‘%ORA-%’ order by originating_timestamp;