Tuesday, February 23, 2021

Cannot access dba_directories inside procedure

 Recently I faced one of familiar Oracle error

ORA-00942: table or view does not exist 


I got it in while compiling procedure, because eventually I found it became invalid state.


I tried to create new directory and give read/write permission on it and change inside procedure, but it still was INVALID. But instead


inside procedure I put hard code path of that directory it  was success.


Like:

create or replace procedure `procedure_name`
(
`variable` IN varchar2
)
AS
`variable` varchar2(2000) := '/../../dir';

begin

    select ... into `variable` from dba_directories whhere directnory_name = '...';
    ....
    ....

end;



But it is not make sense. Then after google I found to overcome that issue, all I need to grant ALL on dba_directories to user not only READ, WRITE.


As SYS

grant all on dba_diretories to `user`'

then I was able to compile successfully original procedure, no longer need to manipulate procedure.

SQL> set linesize 300
SQL> col object_name for a50
SQL> col owner for a30
SQL> select owner, object_name, object_type from dba_objects where status = 'INVALID';  2

OWNER       OBJECT_NAME OBJECT_TYPE
----------------------       --------------------------------                          -----------------
`USER`            `PROCEDURE_NAME`  PROCEDURE

SQL> alter procedure `user`.`precedure_name` compile;
Procedure altered.

SQL> select owner, object_name, object_type from dba_objects where status = 'INVALID';
no rows selected



Friday, April 24, 2020

How to fix : ORA-03113: end-of-file on communication channel

Today when I tried to open my db (that db was created and lunched inside container) I saw ORA-03113: end-of-file on communication channel.


 SQL> startup  
 ORACLE instance started.  
 Total System Global Area 3.4206E+10 bytes  
 Fixed Size   2270360 bytes  
 Variable Size  3422554984 bytes  
 Database Buffers 3.0736E+10 bytes  
 Redo Buffers   45649920 bytes  
 Database mounted.  
 ERROR at line 1:  
 ORA-03113: end-of-file on communication channel  
 Process ID: 11344  
 Session ID: 380 Serial number: 3 



There is a lot of reason can be, after check it out from the forum all I need is clear unarchivelog.

First start instance mount mode.


 SQL> startup mount  
 ORACLE instance started.  
 Total System Global Area 3.4206E+10 bytes  
 Fixed Size   2270360 bytes  
 Variable Size  3422554984 bytes  
 Database Buffers 3.0736E+10 bytes  
 Redo Buffers   45649920 bytes  
 Database mounted.Database mounted. 



-check how many group we have:


SQL> set linesize 200  
 SQL> select group#, members, status from v$log;  
   GROUP#  MEMBERS STATUS  
 ---------- ---------- ----------------  
  1   2 INACTIVE  
  2   2 INACTIVE  
  3   2 INACTIVE  
  4   2 INACTIVE  
  5   2 INACTIVE  
  6   2 CURRENT  
  14   2 INACTIVE  
  8   2 INACTIVE  
  9   2 INACTIVE  
  10   2 INACTIVE  
  11   2 INACTIVE  
   GROUP#  MEMBERS STATUS  
 ---------- ---------- ----------------  
  12   2 INACTIVE  
  13   2 INACTIVE  
  7   2 INACTIVE  
 14 rows selected.  
 SQL>  


Writing this simple PLSQL anonyms block to clear unarchived log files.



SQL> BEGIN FOR i IN 1 .. 14 LOOP execute immediate 'alter database clear unarchived logfile group '||i; END LOOP; END; / PL/SQL procedure successfully completed. SQL>


--look alertlog
alter database clear unarchived logfile group 13
WARNING! CLEARING REDO LOG WHICH HAS NOT BEEN ARCHIVED. BACKUPS TAKEN
    BEFORE 04/15/2020 12:35:11 (CHANGE 228093) CANNOT BE USED FOR RECOVERY.
Clearing online log 13 of thread 1 sequence number 195
Completed: alter database clear unarchived logfile group 13
alter database clear unarchived logfile group 14
WARNING! CLEARING REDO LOG WHICH HAS NOT BEEN ARCHIVED. BACKUPS TAKEN
    BEFORE 04/15/2020 12:40:12 (CHANGE 228198) CANNOT BE USED FOR RECOVERY.
Clearing online log 14 of thread 1 sequence number 196
Wed Apr 15 15:22:49 2020
Completed: alter database clear unarchived logfile group 14




you can restart db or just try to switch from mount mode to open

alter database open;

or

 SQL> shut immediate  
 ORA-01109: database not open  
 Database dismounted.  
 ORACLE instance shut down.  
 SQL>  
 SQL> startup  
 ORACLE instance started.  
 Total System Global Area 3.4206E+10 bytes  
 Fixed Size   2270360 bytes  
 Variable Size  3422554984 bytes  
 Database Buffers 3.0736E+10 bytes  
 Redo Buffers   45649920 bytes  
 Database mounted.  
 Database opened.  
 SQL>  




Monday, December 26, 2016

Fix ORA-01139: RESETLOGS option only valid after an incomplete database recovery

While shutting down my TEST database process was hanged. Then I had to use shutdown abort. But when I wanted to start database it did not open.


 SQL> select name from v$database;  
 NAME  
 ---------  
 TEST

SQL> shut abort;  
 ORACLE instance shut down.  
 SQL> startup mount  
 ORACLE instance started.  
 Total System Global Area 6597406720 bytes  
 Fixed Size                2265664 bytes  
 Variable Size           3204451776 bytes  
 Database Buffers       3372220416 bytes  
 Redo Buffers            18468864 bytes  
 Database mounted.  
 SQL> alter database open;  
 alter database open  
 *  
 ERROR at line 1:  
 ORA-03113: end-of-file on communication channel  
 Process ID: 6552  
 Session ID: 191 Serial number: 3 

 What`s wrong? 

 SQL> alter database open resetlogs;  
 ERROR:   
 ORA-03114: not connected to ORACLE  

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

And instance got down

$ ps -ef | grep smon
oracle    6586  6246  0 17:50 pts/2    00:00:00 grep smon

 $ sqlplus "/as sysdba"  
 SQL*Plus: Release 11.2.0.4.0 Production on Mon Dec 26 17:50:35 2016  
 Copyright (c) 1982, 2013, Oracle. All rights reserved.  
 Connected to an idle instance.  
 SQL> startup mount  
 ORACLE instance started.  
 Total System Global Area 6597406720 bytes  
 Fixed Size                2265664 bytes  
 Variable Size           3204451776 bytes  
 Database Buffers       3372220416 bytes  
 Redo Buffers            18468864 bytes  
 Database mounted.  

Tried to reset logs

SQL> alter database open resetlogs;  
 alter database open resetlogs  
 *  
 ERROR at line 1:  
 ORA-01139: RESETLOGS option only valid after an incomplete database recovery 

Unsuccessful...
Let`s recover database 

SQL> recover database until cancel;  
 Media recovery complete.  

Now, try to open with resetlogs

 SQL> alter database open resetlogs;  
 Database altered. 


Done, now it works

Tuesday, November 1, 2016

ORA-29339: tablespace block size 16384 does not match configured block sizes

While I create non standart db_block_size tablespace I faced ORA-29339: tablespace block size 16384 does not match configured block sizes.

16k = 16*1024 = 16384

 SQL> CREATE TABLESPACE DATA DATAFILE  
  '/u01/app/oracle/oradata/cdb1/TEST/data01.dbf' SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 31G  
 LOGGING  
 DEFAULT  
  NO INMEMORY  
 EXTENT MANAGEMENT LOCAL AUTOALLOCATE  
 BLOCKSIZE 16K  
 SEGMENT SPACE MANAGEMENT AUTO  
 FLASHBACK ON;  

ORA-29339

 SQL> select name, block_size, current_size from v$buffer_pool;  
 NAME                 BLOCK_SIZE CURRENT_SIZE  
 -------------------- ---------- ------------  
 DEFAULT              8192       132096  

Check db_*k_cache_size parameters

SQL> show parameter cache_size  
 NAME     TYPE VALUE  
 ------------------------------------ ----------- ------------------------------  
 client_result_cache_size   big integer 0  
 db_16k_cache_size    big integer 0  
 db_2k_cache_size    big integer 0  
 db_32k_cache_size    big integer 0  
 db_4k_cache_size    big integer 0  
 db_8k_cache_size    big integer 0  
 db_cache_size    big integer 0  
 db_flash_cache_size    big integer 0  
 db_keep_cache_size    big integer 0  
 db_recycle_cache_size    big integer 0  
 SQL>  

Also db_block_size

 SQL> show parameter db_block_size  
 NAME     TYPE VALUE  
 ------------------------------------ ----------- ------------------------------  
 db_block_size    integer 8192  
 SQL>  


I need to set db_16k_cache_size.
 SQL> alter system set db_16k_cache_size = 128M scope=both; 


Then try again


 SQL> CREATE TABLESPACE DATA DATAFILE  
  '/u01/app/oracle/oradata/cdb1/TEST/data01.dbf' SIZE 100M AUTOEXTEND ON NEXT 10M MAXSIZE 31G  
 LOGGING  
 DEFAULT  
  NO INMEMORY  
 EXTENT MANAGEMENT LOCAL AUTOALLOCATE  
 BLOCKSIZE 16K  
 SEGMENT SPACE MANAGEMENT AUTO  
 FLASHBACK ON;  
 Tablespace created.  

Tuesday, March 29, 2016

Fix: ORA-13639: The current operation was interrupted because it timed out.

Sometimes SQL Tuning Advisor interrupts cause time limit took more than defined. You have to analyze it or increase value. Here you can see increasing of value.

Example result of sql

select
                 execution_name, advisor_name,
                 to_char(execution_start,'dd-mon-yy hh:mi:ss') execution_start,
                 to_char(execution_end,'dd-mon-yy hh:mi:ss') execution_end, status,error_message
from dba_advisor_executions
where task_name = 'SYS_AUTO_SQL_TUNING_TASK'
order by execution_start;



Check value of TIME_LIMIT`s parameter :

SQL> column parameter_value for A35   
 SQL> select   
      parameter_name, parameter_value   
      from dba_advisor_parameters   
      where task_name = 'SYS_AUTO_SQL_TUNING_TASK'   
      and parameter_name in ('TIME_LIMIT',   
                            'DEFAULT_EXECUTION_TYPE',   
                            'LOCAL_TIME_LIMIT'); 
 
 PARAMETER_NAME                 PARAMETER_VALUE  
 ------------------------------ ------------------------------  
 LOCAL_TIME_LIMIT                1200  
 TIME_LIMIT                      3600  
 DEFAULT_EXECUTION_TYPE          TUNE SQL  

In our case it is default value. Let`s increase it

 SQL> begin   
 DBMS_SQLTUNE.SET_TUNING_TASK_PARAMETER(task_name => 'SYS_AUTO_SQL_TUNING_TASK', parameter => 'TIME_LIMIT', value => 7200);   
 end;   
 / 2  3  4   
 PL/SQL procedure successfully completed. 

Check again:
 PARAMETER_NAME,             PARAMETER_VALUE  
 LOCAL_TIME_LIMIT,           1200  
 TIME_LIMIT,                 7200  
 DEFAULT_EXECUTION_TYPE,     TUNE SQL 

Friday, December 18, 2015

Fix RMAN-03002

If you face ORA-19804 error just increase db_recovery_file_dest_size value

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup plus archivelog command at 12/18/2015 15:10:43

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/18/2015 15:10:40
ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 52428800 bytes disk space from 214748364800 limit

SQL> set linesize 120  
 SQL> col name for a40  
 \SQL> col type for a40  
 SQL> show parameter db_re  
 NAME                       TYPE         VALUE  
 -------------------------  ---------    ----------------------------  
 db_recovery_file_dest      string       /u01/app/oracle/flash_recovery_area  
 db_recovery_file_dest_size big integer  200G  
 db_recycle_cache_size      big integer  0  


 SQL> alter system set db_recovery_file_dest_size=600G scope=both;  
 System altered.  
That`s all.

Friday, November 27, 2015

Fix ORA-16072

Today after restore and recovery prod database on test environment I faced with strange error:

ORA-16072: a minimum of one standby database destination is required.

My database environment :

 OS: OEL 6.5  
 DB: 11.2.0.4  

After recovery database stays on MOUNT mode and could not open it.

RMAN-00571: ===========================================================  
 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============  
 RMAN-00571: ===========================================================  
 RMAN-03002: failure of recover command at 11/27/2015 12:55:01  
 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 9573 and starting SCN of 556583605 

RMAN> alter database open resetlogs;  
 RMAN-00571: ===========================================================  
 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============  
 RMAN-00571: ===========================================================  
 RMAN-03002: failure of alter db command at 11/27/2015 12:56:08  
 ORA-03113: end-of-file on communication channel  
 Process ID: 12064  
 Session ID: 958 Serial number: 11  
 RMAN-00571: ===========================================================  
 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============  
 RMAN-00571: ===========================================================  
 ORA-03114: not connected to ORACLE  
 RMAN-00571: ===========================================================  
 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============  
 RMAN-00571: ===========================================================  
 RMAN-03002: failure of alter db command at 11/27/2015 12:56:08  
 ORA-03113: end-of-file on communication channel  
 Process ID: 12064  
 Session ID: 958 Serial number: 11  
 [oracle@TESTDB dbs]$  


Checking alertlog:
LGWR: STARTING ARCH PROCESSES  
 Fri Nov 27 14:44:35 2015  
 ARC0 started with pid=22, OS id=23775   
 ARC0: Archival started  
 LGWR: STARTING ARCH PROCESSES COMPLETE  
 ARC0: STARTING ARCH PROCESSES  
 LGWR: Primary database is in MAXIMUM AVAILABILITY mode  
 LGWR: Destination LOG_ARCHIVE_DEST_1 is not serviced by LGWR  
 LGWR: Minimum of 1 LGWR standby database required  
 Errors in file /u01/oracle/diag/rdbms/prod/XXXX/trace/XXXX_lgwr_23742.trc:  
 ORA-16072: a minimum of one standby database destination is required 


I turned off archivelog mode on my test database and tried to open. It opened successfully. But I need my test database have to be on archivelog mode.

To handle it I checked and corrected some parameters:

SQL> select open_mode, log_mode from v$database;  
 OPEN_MODE   LOG_MODE  
 -------------------- ------------  
 READ WRITE   NOARCHIVELOG  



SQL> set linesize 100  
 SQL> show parameter fal_  
 NAME     TYPE     VALUE  
 ------------------------------------ -------------------------------- ------------------------------  
 fal_client    string     XXXX  
 fal_server    string     XXXX_SB  
 SQL> alter system set fal_client='' scope=spfile;  
 System altered.  
 SQL> alter system set fal_server='' scope=spfile;  
 System altered.  
 SQL> alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST';  
 System altered  
 SQL> select open_mode, DATABASE_ROLE, guard_status, SWITCHOVER_STATUS from v$database;  
 OPEN_MODE   DATABASE_ROLE  GUARD_S SWITCHOVER_STATUS  
 -------------------- ---------------- ------- --------------------  
 MOUNTED    PRIMARY    NONE  NOT ALLOWED  
 Database altered.  


Restart database

 SQL> shut immediate  
 ORA-01109: database not open  
 Database dismounted.  
 ORACLE instance shut down.  
 SQL> startup mount  
 ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance  
 ORACLE instance started.  
 Total System Global Area 8584982528 bytes  
 Fixed Size   2260128 bytes  
 Variable Size  6341788512 bytes  
 Database Buffers 2214592512 bytes  
 Redo Buffers   26341376 bytes  
 Database mounted.  
 SQL> alter database open;  
 Database altered.  

Perfect

SQL> select name, open_mode from v$database;  
 NAME OPEN_MODE  
 ---------  ------------------------  
 XXXX  READ WRITE  
 SQL>  



But in alertlog still error

 Errors in file /u01/oracle/diag/rdbms/prod/XXXX/trace/XXXX_arct_24125.trc:  
 ORA-00313: open failed for members of log group 7 of thread 0  
 ORA-00312: online log 7 thread 0: '/u01/oracle/fast_recovery_area/XXXX/onlinelog/o1_mf_7_c4vcl2pw_.log' 


There standby redo logs. Let`s drop it

 SQL> select group#, bytes from v$standby_log;  
   GROUP# BYTES  
 ---------- ----------  
  4 314572800  
  5 314572800  
  6 314572800  
  7 314572800  
 SQL> set linesize 150  
 SQL> col member for a80  
 SQL> select group#, member from v$logfile;  
   GROUP# MEMBER  
 ---------- --------------------------------------------------------------------------------  
  1 /u01/oracle/oradata/XXX/redo01.log  
  2 /u01/oracle/oradata/XXX/redo02.log  
  3 /u01/oracle/oradata/XXX/redo03.log  
  4 /u01/oracle/fast_recovery_area/XXX/onlinelog/o1_mf_4_c5jf59f8_.log  
  5 /u01/oracle/fast_recovery_area/XXX/onlinelog/o1_mf_5_c5jf5df9_.log  
  6 /u01/oracle/fast_recovery_area/XXX/onlinelog/o1_mf_6_c5jf5hfv_.log  
  7 /u01/oracle/fast_recovery_area/XXX/onlinelog/o1_mf_7_c5jf5lw1_.log  
 7 rows selected.  


[oracle@TESTDB onlinelog]$ pwd
/u01/oracle/fast_recovery_area/XXXX/onlinelog

[oracle@TESTDB onlinelog]$ ls -lrt  
 total 1228820  
 -rw-r-----. 1 oracle oinstall 314573312 Nov 27 14:47 o1_mf_4_c5jf59f8_.log  
 -rw-r-----. 1 oracle oinstall 314573312 Nov 27 14:47 o1_mf_5_c5jf5df9_.log  
 -rw-r-----. 1 oracle oinstall 314573312 Nov 27 14:47 o1_mf_6_c5jf5hfv_.log  
 -rw-r-----. 1 oracle oinstall 314573312 Nov 27 14:47 o1_mf_7_c5jf5lw1_.log



 SQL> select status, group#, bytes from v$standby_log;  
 STATUS    GROUP#  BYTES  
 ---------- ---------- ----------  
 UNASSIGNED   4 314572800  
 UNASSIGNED   5 314572800  
 UNASSIGNED   6 314572800  
 UNASSIGNED   7 314572800  
 SQL> alter database drop standby logfile group 4;  
 Database altered.  
 SQL> alter database drop standby logfile group 5;  
 Database altered.  
 SQL> alter database drop standby logfile group 6;  
 Database altered.  
 SQL> alter database drop standby logfile group 7;  
 Database altered.  

After restart db check alertlog

SQL> shut immediate  
 Database closed.  
 Database dismounted.  
 ORACLE instance shut down.  
 SQL> startup  
 ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance  
 ORACLE instance started.  
 Total System Global Area 8584982528 bytes  
 Fixed Size   2260128 bytes  
 Variable Size  6341788512 bytes  
 Database Buffers 2214592512 bytes  
 Redo Buffers   26341376 bytes  
 Database mounted.  
 Database opened.  
 SQL>   

Alertlog is clear
Fri Nov 27 15:15:42 2015  
 ALTER DATABASE OPEN  
 LGWR: STARTING ARCH PROCESSES  
 Fri Nov 27 15:15:42 2015  

Sunday, November 22, 2015

Fix ORA-16053

Today I will show you how to handle ORA-16053 error

--Check maximum sequence number of archive log
SQL> select max(sequence#) from v$archived_log;  
 MAX(SEQUENCE#)  
 --------------  
       36  


--Now check parameter
SQL> col destination for a70  
 SQL> select dest_id, status, destination, error from v$archive_dest;  
   DEST_ID STATUS  DESTINATION                              ERROR  
 ---------- --------- ---------------------------------------------------------------------- -----------------------------------------------------------------  
      1 BAD PARAM                                    ORA-16053: DB_UNIQUE_NAME is not in the Data Guard Configuration  
      2 VALID   PROD  
      3 INACTIVE  
      4 INACTIVE  
      5 INACTIVE  
      6 INACTIVE  
      7 INACTIVE  
      8 INACTIVE  
      9 INACTIVE  
     10 INACTIVE  
     11 VALID   /u01/app/oracle/product/11.0.1/db_1/dbs/arch  
 11 rows selected.  

Here is error which means db_unique_name not setted on parameter.


--Also below query provide us bad param if not properly configured.
SQL> select status, dest_id, error from v$archive_dest_status;  
 STATUS    DEST_ID ERROR  
 --------- ---------- -----------------------------------------------------------------  
 BAD PARAM     1 ORA-16053: DB_UNIQUE_NAME is not in the Data Guard Configuration  
 VALID       2  
 INACTIVE      3  
 INACTIVE      4  
 INACTIVE      5  
 INACTIVE      6  
 INACTIVE      7  
 INACTIVE      8  
 INACTIVE      9  
 INACTIVE     10  
 VALID       11  
 11 rows selected.  

SQL> show parameter log_archive_config  
 NAME                 TYPE    VALUE  
 ------------------------------------ ----------- ------------------------------  
 log_archive_config          string   DG_CONFIG=(PROD,STAND)  
 --set log_archive_config  
 SQL> alter system set log_archive_config='DG_CONFIG=(STAND,PROD)';  
 System altered. 


SQL> show parameter log_archive_dest_1  
 NAME                 TYPE    VALUE  
 ------------------------------------ ----------- ------------------------------  
 log_archive_dest_1          string   LOCATION=USE_DB_RECOVERY_FILE_  
                          DEST VALID_FOR=(ALL_LOGFILES,A  
                          LL_ROLES) DB_UNIQUE_NAME=PROD  
 log_archive_dest_10         string  
 SQL> show parameter log_archive_dest_2  
 NAME                 TYPE    VALUE  
 ------------------------------------ ----------- ------------------------------  
 log_archive_dest_2          string   SERVICE=PROD VALID_FOR=(ONLINE  
                          _LOGFILE,PRIMARY_ROLE) async d  
                          b_unique_name=PROD  
 SQL> alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES_ DB_UNIQUE_NAME=STAND' scope=both;  
 System altered.  



SQL> select status, dest_id, error from v$archive_dest_status where dest_id=2;  
 STATUS         DEST_ID ERROR  
 -------------------- ---------- -----------------------------------------------------------------  
 VALID    

 SQL> select dest_id, status, destination, error from v$archive_dest;  
   DEST_ID STATUS        DESTINATION                              ERROR  
 ---------- -------------------- ---------------------------------------------------------------------- -----------------------------------------------------------------  
      1 VALID        USE_DB_RECOVERY_FILE_DEST  
      2 VALID        PROD  
      3 INACTIVE  
      4 INACTIVE  
      5 INACTIVE  
      6 INACTIVE  
      7 INACTIVE  
      8 INACTIVE  
      9 INACTIVE  
     10 INACTIVE  
     11 VALID        USE_DB_RECOVERY_FILE_DEST  
 11 rows selected.  


--Now check again and you will see logs start to receive and applying.

 SQL> select max(sequence#) from v$archived_log;  
 MAX(SEQUENCE#)  
 --------------  
       45  

Monday, November 16, 2015

Fix INS-32025

Sometimes we face "[INS-32025] The chosen installation conflicts with software already installed in the given Oracle home" error when we reinstall Oracle home.



To fix this error, go to oraInventory folder.


cd /u01/oraInventory/ContentsXML --this is my folder
edit inventory.xml any editor
remove below line:

<HOME NAME="OraDb11g_home1" LOC="/u01/oracle/product/11.2.0/dbhome_1" TYPE="O" IDX="1"/>

execute runInstaller again

Thursday, November 5, 2015

List of most used tables

I requested to gather most used tables list in production database.
After investigation I found some advice and of course metalink note.

Here is OTN link:  https://forums.oracle.com/forums/thread.jspa?threadID=511661


Use below query.

SQL> SELECT ROWNUM AS RANK, Seg_Lio.*  
  FROM ( SELECT St.Owner,  
          St.Obj#,  
          St.Object_Type,  
          St.Object_Name,  
          St.VALUE,  
          'LIO' AS Unit  
       FROM V$segment_Statistics St  
       WHERE St.Statistic_Name = 'logical reads'  
     ORDER BY St.VALUE DESC) Seg_Lio  
 WHERE owner not in ('SYS', 'SYSTEM') and object_type='TABLE' and ROWNUM <= 20  
 UNION ALL  
 SELECT ROWNUM AS RANK, Seq_Pio_r.*  
  FROM ( SELECT St.Owner,  
          St.Obj#,  
          St.Object_Type,  
          St.Object_Name,  
          St.VALUE,  
          'PIO Reads' AS Unit  
       FROM V$segment_Statistics St  
       WHERE St.Statistic_Name = 'physical reads'  
     ORDER BY St.VALUE DESC) Seq_Pio_r  
 WHERE owner not in ('SYS', 'SYSTEM') and object_type='TABLE' and ROWNUM <= 20  
 UNION ALL  
 SELECT ROWNUM AS RANK, Seq_Pio_w.*  
  FROM ( SELECT St.Owner,  
          St.Obj#,  
          St.Object_Type,  
          St.Object_Name,  
          St.VALUE,  
          'PIO Writes' AS Unit  
       FROM V$segment_Statistics St  
       WHERE St.Statistic_Name = 'physical writes'  
     ORDER BY St.VALUE DESC) Seq_Pio_w  
 WHERE owner not in ('SYS', 'SYSTEM') and object_type='TABLE' and ROWNUM <= 20  
 UNION ALL  
 SELECT ROWNUM AS RANK, Seq_Pio_w.*  
  FROM ( SELECT St.Owner,  
          St.Obj#,  
          St.Object_Type,  
          St.Object_Name,  
          St.VALUE,  
          'PIO READS Direct' AS Unit  
       FROM V$segment_Statistics St  
       WHERE St.Statistic_Name = 'physical reads direct'  
     ORDER BY St.VALUE DESC) Seq_Pio_w  
 WHERE owner not in ('SYS', 'SYSTEM') and object_type='TABLE' and ROWNUM <= 20  
 UNION ALL  
 SELECT ROWNUM AS RANK, Seq_Pio_w.*  
  FROM ( SELECT St.Owner,  
          St.Obj#,  
          St.Object_Type,  
          St.Object_Name,  
          St.VALUE,  
          'DB Block changes' AS Unit  
       FROM V$segment_Statistics St  
       WHERE St.Statistic_Name = 'db block changes'  
     ORDER BY St.VALUE DESC) Seq_Pio_w  
 WHERE owner not in ('SYS', 'SYSTEM') and object_type='TABLE' and ROWNUM <= 20  
For detail please refer to metalink note: 252597.1

Also you may select below views to get some necessary information.

--tables which modificated
 SQL> select * from dba_tab_modifications where table_owner='????' 

Starting Oracle 11g if your statistics_level`s value TYPICAL Oracle automatically will gather and monitor your tables.

--List of monitored tables
SQL> select * from dba_tables where owner='?????' and monitoring='YES' 


 SQL> select owner, monitoring, count(1)   
 from dba_tables   
 group by owner, monitoring   
 order by 1, count(1) 




Thursday, October 29, 2015

Fix ORA-08104

While rebuilding index my toad session was hanged and I decided to kill session but it also hanged

SQL> alter index xxx.xxxxx rebuild online parallel 8;

To fix it I connected db with new sesssion and got object_id of mentioned index

 SQL> select object_id obj#, i.status from dba_indexes i, dba_objects o  
 where o.object_name=i.index_name and  
 i.index_name='LOYAL_RES_IDX1';


--Note flags
SQL> select flags from ind$ where obj#=356001; 


Using DBMS_REPAIR package clean index

SQL> declare  
 isclean boolean;  
 begin  
 isclean :=false;  
 while isclean=false loop  
 isclean := DBMS_REPAIR.ONLINE_INDEX_CLEAN  
 (dbms_repair.all_index_id,dbms_repair.lock_wait);  
 dbms_lock.sleep(10);  
 end loop;  
 end;  
 /  


--Note flags
 SQL> select flags from ind$ where obj#=356001; 


As you see it was decreased and normal

Cannot access dba_directories inside procedure

 Recently I faced one of familiar Oracle error ORA -00942 : table or view does not exist   I got it in while compiling procedure, becaus...