Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all 1640 articles
Browse latest View live

Article 8

$
0
0

Script to check the Database status in HTML format


set lines 200
col FIRST_CHANGE# format 999999999999999
col NEXT_CHANGE# format 999999999999999
col name format a60
col member format a70
spool db-current-status.html
set markup html on
alter session set nls_date_format = 'dd/mm/yyyy hh24:mi:ss';
select HXFIL File_num,substr(HXFNM,1,75) name,FHTYP Type,HXERR Validity,FHSCN SCN, FHTNM TABLESPACE_NAME,FHSTA status ,FHRBA_SEQ Sequence from X$KCVFH;
select count(*) ,fhrba_seq,FHTHR from x$kcvfh group by fhrba_seq,FHTHR;
select count(*) ,fhsta from x$kcvfh group by fhsta;
select count(*) ,FHSCN,FHTHR from x$kcvfh group by FHSCN,FHTHR;
select file#,error from v$datafile_header where length(error)>=1;
select * from gv$log;
select group#,member from v$logfile;
select distinct(status)from v$datafile;
select FILE#,TS# , status, NAME from v$datafile where status not in ('SYSTEM','ONLINE') order by 1;
select count(*) from v$backup where status = 'ACTIVE';
select name,dbid,CONTROLFILE_TYPE,OPEN_RESETLOGS,open_mode,log_mode from v$database;
select DISTINCT (TO_CHAR (CHECKPOINT_TIME)) ,count(*) from V$DATAFILE_HEADER group by CHECKPOINT_TIME;
select * from v$database_incarnation;
set markup html off
spool off


Article 7

$
0
0

Script to get the Metadata of all Dblinks in the Database



set lines 240
set echo off
set feedb off
set termout off
set heading off
SET VERIFY off
set trimspool on
set long 32766
set longchunksize 120
col l1 format a80
col l2 format a160 newline

define spoolfile=/tmp/metadata_all_dblinks_out.sql
spool &spoolfile

select 'select '||''''||'-- '||owner||'.'||db_link||''''||' from dual; ' l1,
       'select dbms_metadata.get_ddl('||''''||'DB_LINK'||''''||','||
       ''''||db_link||''''||','||''''||owner||''''||') from dual; ' l2
from dba_db_links
order by owner, db_link
/
spool off
set termout on

@&spoolfile

set echo on
set feedb on
set heading on
SET VERIFY on

undefine spoolfile

Article 6

$
0
0

Script to check the Scheduled Jobs in the Database



set lines 200
col owner     format a12
col username  format a12
col job       format a30
col instance  format a12
col last_date format a20
col next_date format a20
col enabled   format a7

ttitle "Scheduled jobs ..." left

SELECT OWNER, JOB_NAME job, TO_CHAR(LAST_START_DATE,'mm/dd/yyyy hh24:mi:ss') last_date,
    TO_CHAR(NEXT_RUN_DATE,'mm/dd/yyyy hh24:mi:ss') next_date, ENABLED
FROM DBA_SCHEDULER_JOBS
WHERE ENABLED='TRUE'
-- AND OWNER <> 'SYS'
UNION ALL
SELECT SCHEMA_USER owner, 'dba_jobs -- '||TO_CHAR(job) job, TO_CHAR(LAST_DATE,'mm/dd/yyyy hh24:mi:ss') last_date,
    TO_CHAR(NEXT_DATE,'mm/dd/yyyy hh24:mi:ss') next_date, DECODE(broken , 'Y', 'FALSE', 'TRUE') enabled
FROM DBA_JOBS
ORDER BY 1,2
/

ttitle off

Article 5

$
0
0

Script to add new Standby Logfile



col member format a60
set lines 200
set pages 999
set serveroutput on size 1000000

DECLARE
    CURSOR c_inst IS
        SELECT thread#, MIN(GROUP#) min_group, MAX(GROUP#) max_group, sum(members) cnt
        FROM v$log
        GROUP BY thread#
        ORDER BY thread#;

    CURSOR c_log (pTHREAD# IN NUMBER) IS
        SELECT lf.group#, lf.member, l.thread#, l.sequence#, l.bytes/1024/1024 mb, lf.status
        FROM v$logfile lf, v$log l
        WHERE lf.group# = l.group#
          AND l.thread# = pTHREAD#
          -- AND lf.INST_ID = l.INST_ID
          -- AND l.thread# = (SELECT MAX(thread#) FROM gv$log)
        ORDER BY lf.group#, lf.member;

    lv_thread      NUMBER         := 0;
    lv_group_Min   NUMBER         := 0;
    lv_group_Max   NUMBER         := 0;
    lv_group_tot   NUMBER         := 0;
    lv_group_Cur   NUMBER         := 0;
    lv_group_Last  NUMBER         := 0;
    lv_case        NUMBER         := 0;
    lv_members     NUMBER         := 0;
    lv_cnt         NUMBER         := 0;
    lv_redo_seq    VARCHAR2(12)   := NULL;
    lv_debug       BOOLEAN        := FALSE;
    -- lv_debug       BOOLEAN        := TRUE;
    lv_sql         VARCHAR2(4000) := NULL;
    lv_keyword     VARCHAR2(8)    := 'redo';
    lv_last_gp     NUMBER         := 0;
    lv_last_member varchar2(80);
    lv_last_size   NUMBER         := 0;
    lv_last_seq    VARCHAR2(12)   := NULL;

    FUNCTION logfile_count (p_logfile_type VARCHAR2 DEFAULT 'ONLINE')
    RETURN INTEGER
    IS
        lv_cnt INTEGER := 0;
    BEGIN
        SELECT COUNT(*) INTO lv_cnt
        FROM v$logfile
        WHERE type = UPPER(p_logfile_type);    -- 'STANDBY';
        RETURN lv_cnt;

        EXCEPTION
            WHEN NO_DATA_FOUND THEN
                RETURN 0;
            WHEN OTHERS THEN
                RETURN NULL;
    END logfile_count;
BEGIN
    IF logfile_count ('STANDBY') > 3 THEN
       RETURN;
    END IF;

    BEGIN
        SELECT MAX(GROUP#)
          INTO lv_group_tot
        FROM V$LOGFILE;

        EXCEPTION
            WHEN NO_DATA_FOUND THEN
                lv_group_max := 0;
            WHEN OTHERS THEN
                RAISE;
    END;

    FOR c_inst_rec IN c_inst LOOP
           lv_thread := c_inst_rec.thread#;
           lv_group_min := c_inst_rec.min_group;
           lv_group_max := c_inst_rec.max_group;
           lv_members := c_inst_rec.cnt;

        IF lv_debug THEN
            DBMS_OUTPUT.PUT_LINE ('lv_group_min='||TO_CHAR(lv_group_min)||'  lv_group_max='||TO_CHAR(lv_group_max)||
                                  '  lv_members='||TO_CHAR(lv_members));
        END IF;

        lv_sql := 'ALTER DATABASE ADD STANDBY LOGFILE THREAD '||TO_CHAR(lv_thread);
        DBMS_OUTPUT.PUT_LINE (lv_sql);
        IF lv_debug THEN
            DBMS_OUTPUT.PUT_LINE (lv_sql);
        END IF;
        lv_group_cur := lv_group_tot + lv_group_min;

        IF lv_debug THEN
            DBMS_OUTPUT.PUT_LINE ('lv_group_cur='||TO_CHAR(lv_group_cur)||'  lv_group_max='||TO_CHAR(lv_group_max));
        END IF;

        lv_cnt := 0;
        FOR c_log_rec IN c_log (lv_thread) LOOP
            IF lv_debug THEN
                DBMS_OUTPUT.PUT_LINE ('The current group is : '||TO_CHAR(lv_group_cur));
            END IF;

            LV_REDO_SEQ := lv_keyword||LPAD(TO_CHAR(lv_thread), 2, '0')||'_'||LPAD(TO_CHAR(lv_group_cur), 2,'0')||'_sb';

            IF lv_members = 2*(lv_group_max-lv_group_min+1) THEN
              BEGIN
                IF lv_group_last <> c_log_rec.group# THEN
                    IF lv_cnt = 0 THEN
                        DBMS_OUTPUT.PUT_LINE ('  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                           REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                   INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                   lv_redo_seq)||''''||' ) SIZE ' || TO_CHAR(c_log_rec.MB) ||'M REUSE');
                        lv_sql := lv_sql||'  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                                  REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                   INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                          lv_redo_seq)||'''';
                    ELSE
                        DBMS_OUTPUT.PUT_LINE (',  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                            REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                   INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                    lv_redo_seq)||''''||' ) SIZE ' || TO_CHAR(c_log_rec.MB) ||'M REUSE');
                        lv_sql := lv_sql||',  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                                  REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                   INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                          lv_redo_seq)||'''';
                    END IF;
                    lv_group_last := c_log_rec.group#;
                    lv_group_cur := lv_group_cur + 1;
                END IF;
              END;
            ELSIF lv_members = lv_group_max-lv_group_min+1 THEN
              BEGIN
                IF lv_group_last <> c_log_rec.group# THEN
                    IF lv_cnt = 0 THEN
                        DBMS_OUTPUT.PUT_LINE ('  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                           REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                   INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                   lv_redo_seq)||''''||') SIZE ' ||TO_CHAR(c_log_rec.MB) ||'M REUSE');
                        lv_sql := lv_sql||'  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                                  REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                          INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                          lv_redo_seq)||''''||') SIZE ' ||TO_CHAR(c_log_rec.MB) ||'M REUSE';
                    ELSE
                        DBMS_OUTPUT.PUT_LINE (',  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                            REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                    INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                    lv_redo_seq)||''''||') SIZE ' ||TO_CHAR(c_log_rec.MB) ||'M REUSE');
                        lv_sql := lv_sql||',  GROUP '||TO_CHAR(lv_group_cur)||' ('||''''||
                                  REPLACE(c_log_rec.member, lv_keyword||SUBSTR(c_log_rec.member,
                                          INSTR(c_log_rec.member, lv_keyword)+LENGTH(lv_keyword), 2),
                                          lv_redo_seq)||''''||') SIZE ' ||TO_CHAR(c_log_rec.MB) ||'M REUSE';
                    END IF;
                    lv_group_last := c_log_rec.group#;
                    lv_group_cur := lv_group_cur + 1;
                END IF;

                IF lv_debug THEN
                    DBMS_OUTPUT.PUT_LINE ('LV_REDO_SEQ='||TO_CHAR(LV_REDO_SEQ));
                    DBMS_OUTPUT.PUT_LINE ('lv_group_cur='||TO_CHAR(lv_group_cur));
                END IF;

              END;
            END IF;
            LV_CNT := LV_CNT + 1;
            lv_last_gp := lv_group_cur;
            lv_last_member := c_log_rec.member;
            lv_last_size := c_log_rec.MB;
            -- lv_last_seq := lv_keyword||LPAD(TO_CHAR(lv_thread), 2, '0')||'_sb';
            lv_last_seq := lv_keyword||LPAD(TO_CHAR(lv_thread), 2, '0')||'_'||LPAD(TO_CHAR(lv_last_gp), 2,'0')||'_sb';
        END LOOP;
        -- One extra logfile
        DBMS_OUTPUT.PUT_LINE (',  GROUP '||TO_CHAR(lv_last_gp)||' ('||''''|| REPLACE(lv_last_member, lv_keyword||
             SUBSTR(lv_last_member, INSTR(lv_last_member, lv_keyword)+LENGTH(lv_keyword), 2), lv_last_seq)||''''||
             ' ) SIZE ' || TO_CHAR(lv_last_size) ||'M REUSE');
         lv_sql := lv_sql||',  GROUP '||TO_CHAR(lv_last_gp)||' ('||''''|| REPLACE(lv_last_member, lv_keyword||
             SUBSTR(lv_last_member, INSTR(lv_last_member, lv_keyword)+LENGTH(lv_keyword), 2), lv_last_seq)||'''';
        DBMS_OUTPUT.PUT_LINE ('/ ');
        -- DBMS_OUTPUT.PUT_LINE (lv_sql);
        -- EXECUTE IMMEDIATE lv_sql;
    END LOOP;
END;
/

Find objects size in MBytes (TABLES, INDEXES, PARTITIONS etc)

$
0
0


Summary

Finding object size in Oracle database is very important and common.
Is it very useful to know the exact size occupied by the object at the tablespace.
The object size in the following scripts is in Mbytes. The scripts have been formatted to work very easily .

For example you can filter with tablespace_name, or owner, or size (for example more than 1GByte)

SELECT owner, segment_name, segment_type, partition_name, ROUND(bytes/(1024*1024),2) SIZE_MB, tablespace_name
FROM DBA_SEGMENTS
WHERE SEGMENT_TYPE IN ('TABLE', 'TABLE PARTITION', 'TABLE SUBPARTITION',
'INDEX', 'INDEX PARTITION', 'INDEX SUBPARTITION', 'TEMPORARY', 'LOBINDEX', 'LOBSEGMENT', 'LOB PARTITION')
--AND TABLESPACE_NAME LIKE 'COSTE%'
--AND SEGMENT_NAME LIKE 'P2010201%'
--AND partition_name LIKE 'P20100201%'
--AND segment_type = 'TABLE'
--AND OWNER = 'TEST_POC'
--AND ROUND(bytes/(1024*1024),2) > 1000
ORDER BY bytes DESC;

You can group by tablespace, owner and segment type and see the total space occupied in MBytes
SELECT tablespace_name, owner, segment_type "Object Type",
       COUNT(owner) "Number of Objects",
       ROUND(SUM(bytes) / 1024 / 1024, 2) "Total Size in MB"
FROM   sys.dba_segments
WHERE  tablespace_name IN ('TEST')
GROUP BY tablespace_name, owner, segment_type
ORDER BY tablespace_name, owner, segment_type;

Article 3

$
0
0

Script to drop Standby Logfile


COL MEMBER FORMAT A48

SET SERVEROUTPUT ON SIZE 1000000


DECLARE
    lv_sql_1 VARCHAR2(400) := 'ALTER DATABASE DROP STANDBY LOGFILE GROUP ';
    lv_sqL   VARCHAR2(400) := NULL;

    CURSOR c_log IS
        select TO_CHAR(GROUP#) group_no,STATUS,TYPE,MEMBER,IS_RECOVERY_DEST_FILE
        from v$logfile
        where type ='STANDBY';

BEGIN
    FOR c_log_rec IN c_log LOOP
        lv_sql := lv_sql_1 ||c_log_rec.group_no;
        EXECUTE IMMEDIATE lv_sql ;
        DBMS_OUTPUT.PUT_LINE(lv_sql);
    END LOOP;
END;
/

Buffer Pool used

$
0
0


Summary


You know that you can define the size of each buffer pool in the buffer_cache as you like, but how much of them is used? Use this script first to find how buffer pools are set.
SELECT SUBSTR(NAME, 0, 22) NAME, SUBSTR(display_value, 0,10) VALUE
FROM v$parameter
WHERE NAME IN ('db_keep_cache_size', 'db_recycle_cache_size', 'db_cache_size');

NAME                   VALUE
---------------------- ----------
db_cache_size          30G
db_keep_cache_size     1G
db_recycle_cache_size  1G

The following script shows how much of each pool is used
SELECT DECODE(kcbwbpd.bp_name, 'DEFAULT', 'db_cache_size', 'RECYCLE',
'db_recycle_cache_size', 'KEEP', 'db_keep_cache_size')
buffer_pool_name, ROUND((COUNT(*)*:block_size)/(1024*1024),2) USED_MB
FROM x$kcbwds kcbwds, x$kcbwbpd kcbwbpd , x$bh bh
WHERE kcbwds.set_id >= kcbwbpd.bp_lo_sid
AND kcbwds.set_id <= kcbwbpd.bp_hi_sid
AND kcbwbpd.bp_size != 0
AND kcbwds.addr = bh.set_ds
AND bh.state !=0
GROUP BY kcbwbpd.bp_name;

BUFFER_POOL_NAME         USED_MB
--------------------- ----------
db_cache_size           30358.94
db_recycle_cache_size       2.66
db_keep_cache_size          7.09

Article 1

$
0
0

Scripts to bounce the database to Archivelog mode and Flashback mode



set echo off
set feedb off
set heading off
set verify off
set trimspool on
set lines 200
set define on
SET SERVEROUTPUT ON SIZE 1000000

-- variable sid varchar2
-- col sid new_value sid format a12
-- select sys_context('userenv', 'db_name') sid from dual;
-- select '&&sid' from dual;

define spoolfile=${DBADGM}/tmp/${ORACLE_SID}_bounce_db_alfbon.sql

spool &&spoolfile;

DECLARE
    lv_LOG_MODE     VARCHAR2(12)  := NULL;
    lv_FLASHBACK_ON VARCHAR2(18)  := NULL;
    lv_sql          VARCHAR2(400) := NULL;
BEGIN
    SELECT log_mode, flashback_on
      INTO lv_LOG_MODE, lv_FLASHBACK_ON
    FROM V$DATABASE;

    -- DBMS_OUTPUT.PUT_LINE ('connect / as sysdba');
    IF lv_LOG_MODE='NOARCHIVELOG' AND lv_FLASHBACK_ON='NO' THEN
        DBMS_OUTPUT.PUT_LINE ('shutdown immediate');
        DBMS_OUTPUT.PUT_LINE ('startup mount');
        DBMS_OUTPUT.PUT_LINE ('alter database archivelog;');
        DBMS_OUTPUT.PUT_LINE ('alter database flashback on;' );
        DBMS_OUTPUT.PUT_LINE ('alter database open;');
    ELSIF lv_LOG_MODE='NOARCHIVELOG' AND lv_FLASHBACK_ON='YES' THEN
        DBMS_OUTPUT.PUT_LINE ('shutdown immediate');
        DBMS_OUTPUT.PUT_LINE ('startup mount');
        DBMS_OUTPUT.PUT_LINE ('alter database archivelog;');
        DBMS_OUTPUT.PUT_LINE ('alter database open;');
    ELSIF lv_LOG_MODE='ARCHIVELOG' AND lv_FLASHBACK_ON='NO' THEN
        DBMS_OUTPUT.PUT_LINE ('shutdown immediate');
        DBMS_OUTPUT.PUT_LINE ('startup mount');
        DBMS_OUTPUT.PUT_LINE ('alter database flashback on;' );
        DBMS_OUTPUT.PUT_LINE ('alter database open;');
    ELSE
        DBMS_OUTPUT.PUT_LINE ('@database');
        DBMS_OUTPUT.PUT_LINE ('@dg_database');
    END IF;

    EXCEPTION
        WHEN NO_DATA_FOUND THEN
            RAISE_APPLICATION_ERROR(-20900, SQLERRM);
END;
/

spool off

set termout on
set heading on

@&&spoolfile;
!rm &&spoolfile

undefine spoolfile


Article 0

$
0
0

Scripts to check the nologging tables and indexes


col index_name format a50
col table_name format a50
col db_name format a14
col type format a10

select sys_context('userenv', 'db_name') db_name, owner||'.'||table_name table_name, LOGGING, 'TABLE' type
from dba_tables
where LOGGING ='NO'
  and owner not like '%SYS%'
  and owner not in ('DBSNMP', 'XDB')
  and (owner, table_name) not in (select owner, table_name
                                  from dba_external_tables)
union all
select sys_context('userenv', 'db_name') db_name, owner||'.'||index_name index_name, LOGGING, 'INDEX' type
from dba_indexes
where LOGGING ='NO'
  and owner not like '%SYS%'
  and owner not in ('DBSNMP', 'XDB')
order by 1, 2
/

Java out of memory "java/lang/OutOfMemoryError" in glassfish

$
0
0
Java heap space increase in glass-fish console.

Go to Configurations ---> JVM Setting.

Change  the value  -XX:MaxOermSize=192m to Approximate value
                                -XX:PermSize= 64m to Approximate value
                                





Change the java heap size on Backend:


Go to glassfish config directory :
                                                         1) cd glassfish/domains/domain1/config
                                                                2) Edit the domain.xml find the jvm
                                                                3) Change the value XX:MaxOermSize= ,  -XX:PermSize=              
     





ORA-03134: Connections to this server version are no longer supported

$
0
0


12c Db-link cannot connect 9i Database as per the latest upgrade and the compatibility matrix


    
          1) connecting from 12c to 9i Db by adding another 11g Database in-between.
          2)Connecting 12c Db to 9i Db and vis-versa using db-link ( Doc ID 2320287.1 ) 

EBS R12 Front page is not opening

$
0
0
Hi,


After running the following steps issue has been resolved.

  1).cd $FND_TOP/patch/115/bin
2).perl ojspCompile.pl --compile --flush -p 2
3).Run the autoconfig both db and apps tier
4).bringup the service and test the login



verify the status:
$ADMIN_SCRIPTS_HOME/adopmnctl.sh status

How to export/import full Oracle Apex applications

$
0
0
Script for Apex application and workspace export:

#!/bin/sh
#apex application backup

APPBKP=/u01/oracle/appbkp

WRKSPCBKP=/u01/oracle/wrkbkp

JAVA_HOME=/home/oracle/jdk1.7.0_71

cd /u01/TEST/apex/utilities

export CLASSPATH=/u01/TEST/app/oracle/product/12.1.0/db_1/oui/jlib/classes12.jar:

/home/oracle/jdk1.7.0_71/bin/java oracle.apex.APEXExport -db 172.168.25.11:1526:TEST -user system -password <xxxxxxxxx> -instance

mv f*.sql $APPBKP

#Apex workspace backup
/home/oracle/jdk1.7.0_71/bin/java oracle.apex.APEXExport -db 172.168.25.11:1526:TEST -user system -password <xxxxxxxxx> -expWorkspace

mv w*.sql $WRKSPCBKP



Script for Apex application and workspace import:


#!/bin/sh

#change as your apex schema name
#this script should run current directory where as applcation backup dir or workspace dir

cd /u01/backup
ls -ltr *.sql|awk {'print $9'}>hi.txt
 cat hi.txt|while read line
do
sqlplus "/ as sysdba"<<!
alter session set current_schema = APEX_050000;
@$line
exit;
!
done

Query To Get Concurrent Request ID for a Given Oracle SID

$
0
0



SELECTs.inst_id,a.request_id,s.sid,s.serial#,c.spid
FROMapps.fnd_concurrent_requestsa,gv$processc,gv$sessions
WHEREs.sidin('&SID')
ANDs.paddr=c.addr
ANDa.oracle_process_id=c.spid
ANDa.phase_code=UPPER('R');

ERROR: ORA-00020: maximum number of processes (1000) exceeded

$
0
0


ORA-00020 this error occure when  database exceeds the initialization parameter PROCESSES value.

   1)The  solution will be to increase the PROCESSES parameter,
   2)kill the the unwanted process like local listener connection which is  known to kill.

How to use Goldengate Logdump Utility

$
0
0
Logdump Commands:

Open Logdump
Go to the Oracle GoldenGate Software directory.

[GoldenGate]$ $GG_HOME/logdump

Open a Trail File
To open a trail file and read it’s content, specify the trail file at the logdump prompt. Trail files are usually found in the GoldenGate dirdat directory.

ls -lrt $GG_HOME/dirata
-rw-rw-rw- 1 oracle oinstall 78325 Dec 7 10:38 GG000001
-rw-rw-rw- 1 oracle oinstall 78325 Dec 7 10:42 GG000002
-rw-rw-rw- 1 oracle oinstall 78325 Dec 7 10:55 GG000003
                                             
You can also determine the current trail file directory/name by running the “INFO process_name” command at the ggsci prompt.

Open and view the details of local trail file.

Logdump> OPEN ./dirdat/GG000001
Change the file name and location as required.

Set Output Format
Enable the following options so that you are able to view the results in a readable format in your Logdump sessionL

Set trail file header detail on
The FILEHEADER contains the header details of the currently opened trail file.

Logdump> FILEHEADER DETAIL

Record Header
Logdump> GHDR ON

Set Column Details on
It displays the list of columns, their ID, length, Hex values etc.

Logdump> DETAIL ON

User token details
User token is the user defined information stored in trail, associated with the table mapping statements. The CSN (SCN in Oracle Database) associated with the transaction is available in this section.

Logdump> USERTOKEN DETAIL

Set length of the record to be displayed
In this case it is 128 characters.

Logdump> RECLEN 128
Viewing the Records
To view particular records in the trail files, navigate as below in the local trail file.

First record in the trail file
Here “0” is the beginning of the trial file

Logdump> POS 0
Move to a specific record, at a particular RBA
The “xxxx” is the RBA number.
Logdump> POS xxxx
Next record in the opened trail file
Logdump> N
Or
Logdump> NEXT

Query to monitor the ASM diskgroup daily

$
0
0

Script :


spool /oracle/app/script/log/prod_report_asm.log_asm.log
set serveroutput on
declare
v_diskgroup_name varchar2(50);
v_total_space number(12);
v_free_space number(12);
v_pct_free number(6,3);
begin
for diskgroup_rec in (select name from v$asm_diskgroup)
loop
---- Get the total space for the current diskgroup--
select (total_mb/1024) into v_total_space
from v$asm_diskgroup
where NAME = diskgroup_rec.name;
---- Get the free space for the current diskgroup--
select (free_mb/1024) into v_free_space
from v$asm_diskgroup
where NAME = diskgroup_rec.name;
---- calculate the percent free for the current diskgroup---
v_pct_free := (v_free_space / v_total_space) * 100;
if v_pct_free < 10 then
  dbms_output.put_line(diskgroup_rec.name|| ' Percentage Free is ' || v_pct_free ||'%'||' as on '||to_char(sysdate,'dd-mm-yy hh24:mi:ss'));
else
 dbms_output.put_line('No Diskgroup below 10%');
end if;
end loop;
end;
/
spool off
exit;

Output :


DG01 Percentage Free is 9.033% as on 30-09-18 16:06:19
No Diskgroup below 10%
No Diskgroup below 10%
DG06 Percentage Free is 7.3% as on 30-09-18 16:06:19
No Diskgroup below 10%

DBMS_METADATA.GET_DDL Scripts

$
0
0
To extract package definition from database:

set pagesize 0
set long 90000
SELECT DBMS_METADATA.GET_DDL('PACKAGE','') FROM dual;

To extract package body  definition from database:

set pagesize 0
set long 90000
SELECT DBMS_METADATA.GET_DDL('PACKAGE_BODY','' ) FROM dual;

To extract user definition:

set pagesize 0
set long 100000
select dbms_metadata.get_ddl( 'USER', '' ) from dual
UNION ALL
select dbms_metadata.get_granted_ddl( 'SYSTEM_GRANT', '' ) from dual
UNION ALL
select dbms_metadata.get_granted_ddl( 'OBJECT_GRANT', '' ) from dual
UNION ALL
select dbms_metadata.get_granted_ddl( 'ROLE_GRANT', '' ) from dual;

To extract tablespace definition:

SELECT dbms_metadata.get_ddl('TABLESPACE','&&tbs_name')
FROM dual;

To extract table definition:

SELECT dbms_metadata.get_ddl('TABLE',upper('&tab_nm'),upper('&username')) txt from dual;

To extract index definition created on a table:

SELECT dbms_metadata.get_dependent_ddl('INDEX',upper('&tab_nm'),upper('&username')) txt from dual;

To extract grant given on a table:

SELECT dbms_metadata.get_dependent_ddl('OBJECT_GRANT',upper('&tab_nm'),upper('&username')) txt FROM  dual;

To extract SYNONYM on a given table:

SELECT dbms_metadata.get_ddl('SYNONYM',TABLE_NAME)  txt from dba_synonyms  where TABLE_OWNER in (upper('&username')) and TABLE_NAME=upper(upper('&tab_nm'));

To extract trigger definition:

SELECT dbms_metadata.get_ddl('TRIGGER',upper('&pkg_nm'),upper('&username')) txt from dual;

To extract privilege given on trigger:

SELECT dbms_metadata.get_dependent_ddl('OBJECT_GRANT',upper('&pkg_nm'),upper('&username')) txt FROM  dual;

To extract function from database:

SELECT dbms_metadata.get_ddl('FUNCTION',upper('&pkg_nm'),upper('&username')) txt from dual;

To extract view from database:

SELECT dbms_metadata.get_ddl('VIEW',upper('&view_nm'),upper('&username')) txt from dual;

Check number of sessions per hour for EACH INSTANCE in a RAC environment

$
0
0

Script :


SELECT
to_char(TRUNC(s.begin_interval_time,'HH24'),'DD-MON-YYYY HH24:MI:SS') snap_begin,
r.instance_number instance,
r.current_utilization sessions 
FROM
dba_hist_resource_limit r,
dba_hist_snapshot s
WHERE ( TRUNC(s.begin_interval_time,'HH24'),s.snap_id ) IN

--Select the Maximum of the Snapshot IDs within an hour if all of the snapshot IDs
--have the same number of sessions
SELECT TRUNC(sn.begin_interval_time,'HH24'),MAX(rl.snap_id)
FROM dba_hist_resource_limit rl,dba_hist_snapshot sn
WHERE TRUNC(sn.begin_interval_time) >= TRUNC(sysdate-1)
AND rl.snap_id = sn.snap_id
AND rl.resource_name = 'sessions'
AND rl.instance_number = sn.instance_number
AND ( TRUNC(sn.begin_interval_time,'HH24'),rl.CURRENT_UTILIZATION ) IN
(
--Select the Maximum no.of sessions for a given begin interval time
SELECT TRUNC(s.begin_interval_time,'HH24'),MAX(r.CURRENT_UTILIZATION) "no_of_sess"
FROM dba_hist_resource_limit r,dba_hist_snapshot s
WHERE r.snap_id = s.snap_id
AND TRUNC(s.begin_interval_time) >= TRUNC(sysdate-1)
AND r.instance_number=s.instance_number
AND r.resource_name = 'sessions'
GROUP BY TRUNC(s.begin_interval_time,'HH24')
)
GROUP BY TRUNC(sn.begin_interval_time,'HH24'),CURRENT_UTILIZATION
)
AND r.snap_id = s.snap_id
AND r.instance_number = s.instance_number
AND r.resource_name = 'sessions'
ORDER BY snap_begin,instance
/


Output :



SNAP_BEGIN             INSTANCE   SESSIONS
-------------------- ---------- ----------
29-SEP-2018 00:00:00          1         93
29-SEP-2018 00:00:00          2         89
29-SEP-2018 01:00:00          1         98
29-SEP-2018 01:00:00          2         96
29-SEP-2018 02:00:00          1         99
29-SEP-2018 02:00:00          2         99
29-SEP-2018 03:00:00          1         95
29-SEP-2018 03:00:00          2         94
29-SEP-2018 04:00:00          1        100
29-SEP-2018 04:00:00          2         95
29-SEP-2018 05:00:00          1        102

Check no. of count and datewise occurrence of ORA-1555 alerts from database

$
0
0

Date wise occurrence of ORA-1555


select to_char(begin_time, 'mm/dd/yyyy hh24:mi') "Int.Start",ssolderrcnt "ORA-1555s", maxquerylen "Max Query",unxpstealcnt "UNExp SCnt",UNXPBLKRELCNT "UnEXPblks", expstealcnt "Exp SCnt",EXPBLKRELCNT "ExpBlks",NOSPACEERRCNT nospace from v$undostat where ssolderrcnt>0
order by begin_time;

Total number of ORA-1555s since instance startup


select 'TOTAL # OF ORA-01555 SINCE INSTANCE STARTUP : '|| to_char(startup_time,'DD-MON-YY HH24:MI:SS')
from v$instance;

Viewing all 1640 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>