Tuesday, December 29, 2020

ORA-02030: can only select from fixed tables/views



 grant SELECT access to v$ objects (exp - V$session) to other users?

we can’t grant direct access V$session because v$session is a synonym.

SQL> GRANT SELECT ON v$session TO uday;
grant select on v$session to uday
*
ERROR at line 1:
ORA-02030: can only select from fixed tables/views

— V$SESSION is a public synonym
SQL> SELECT owner, object_type FROM dba_objects WHERE object_name = ‘V$SESSION’;

OWNER OBJECT_TYPE
———————— ——————-
PUBLIC SYNONYM

— the object (table/view) the synonym points to
SQL> select table_owner, table_name FROM dba_synonyms where synonym_name = ‘V$SESSION’;

TABLE_OWNER TABLE_NAME
————– ——————————
SYS V_$SESSION

you cannot grant any privilege to v$ objects  or any other fixed views.  
however,you can grant directly option the base table:

SQL> GRANT SELECT ON V_$SESSION TO scott;

Grant succeeded.






grant SELECT access to v$ objects (exp - V$session) to other users?




 grant SELECT access to v$ objects (exp - V$session) to other users?

we can’t grant direct access V$session because v$session is a synonym.

SQL> GRANT SELECT ON v$session TO uday;
grant select on v$session to uday
*
ERROR at line 1:
ORA-02030: can only select from fixed tables/views

— V$SESSION is a public synonym
SQL> SELECT owner, object_type FROM dba_objects WHERE object_name = ‘V$SESSION’;

OWNER OBJECT_TYPE
———————— ——————-
PUBLIC SYNONYM

— the object (table/view) the synonym points to
SQL> select table_owner, table_name FROM dba_synonyms where synonym_name = ‘V$SESSION’;

TABLE_OWNER TABLE_NAME
————– ——————————
SYS V_$SESSION

you cannot grant any privilege to v$ objects  or any other fixed views.  
however,you can grant directly option the base table:

SQL> GRANT SELECT ON V_$SESSION TO scott;

Grant succeeded.






Monday, December 21, 2020

find database is in BEGIN/END backup mode

 find database is in BEGIN/END backup mode


ALTER DATABASE BEGIN/END BACKUP
To take backup manually or when cloning a database using the following SQL need to be executed
which will place the database in backup mode

SQL> ALTER DATABASE BEGIN BACKUP;
Database altered.

To find if database or any tablespace is in backup mode, 
check the status column in V$BACKUP is ACTIVE

SQL> select * from v$backup;

FILE# STATUS CHANGE# TIME
———- —————— ———- ———
1 ACTIVE 14323567 01-OCT-20
2 ACTIVE 14323567 01-OCT-20
3 ACTIVE 14323567 01-OCT-20
4 ACTIVE 14323567 01-OCT-20

Here FILE# is the datafile number

now you copy the physical database files along with REDOLOGS.
REDOLOGS, will be used for database recover, incase of any pending transactions


to finish the BACKUP mode, execute below query

SQL> ALTER DATABASE END BACKUP;
Database altered.

then, check if database is in backup mode
SQL> select * from v$backup;

FILE# STATUS CHANGE# TIME
———- —————— ———- ———
1 NOT ACTIVE 14323567 01-OCT-20
2 NOT ACTIVE 14323567 01-OCT-20

If you try to shutdown of database when database is in BACKUP mode, 
you will receive the following error “ORA-01149”

SQL> shutdown immediate;
ORA-01149: cannot shutdown – file 1 has online backup set
ORA-01110: data file 1: ‘/u01/oradata/TESTDB/system_01.dbf’




If try to set the database again to BEGIN BACKUP MODE, that is already in backup mode,
you will receive the following error “ORA-01146”

SQL> alter database begin backup;
alter database begin backup
*
ERROR at line 1:
ORA-01146: cannot start online backup – file 1 is already in backup
ORA-01110: data file 1: ‘/u01/oradata/TESTDB/system_01.dbf’

In 9i to set database is backup mode, with  “ALTER DATABASE BEGIN/END BACKUP” doesn’t exists 
so it has to be done at individual tablespace level by executing below
“ALTER TABLESPACE <tablespace> BEGIN/END BACKUP”.

exp:- 
ALTER TABLESPACE SYSTEM BEGIN BACKUP;
ALTER TABLESPACE SYSTEM END BACKUP;

If try to perform incremental backup using RMAN 
it will skip backing up datafiles as datafiles are in backup
and show warning RMAN-06554

RMAN> backup incremental level 1 database;

Starting backup at 01-OCT-20
using channel ORA_DISK_1
RMAN-06554: WARNING: file 1 is in backup mode
RMAN-06554: WARNING: file 2 is in backup mode
RMAN-06554: WARNING: file 3 is in backup mode
RMAN-06554: WARNING: file 4 is in backup mode
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/oradata/TESTDB/sysaux_01.dbf
skipping datafile 00003 because it has not changed
input datafile fno=00001 name=/u01/oradata/TESTDB/system_01.dbf
skipping datafile 00001 because it has not changed
input datafile fno=00002 name=/u01/oradata/TESTDB/undo_01.dbf
skipping datafile 00002 because it has not changed
input datafile fno=00004 name=/u01/oradata/TESTDB/test_01.dbf
skipping datafile 00004 because it has not changed

channel ORA_DISK_1: backup cancelled because all files were skipped








Wednesday, December 16, 2020

OPatch throwing "Unable to lock Central Inventory" on Windows

OPatch throwing "Unable to lock Central Inventory" on Windows


OPatch throwing the following error when trying to apply or rollback a patch:

C:\Users\oracle\Desktop\31654782>G:\oracle\product\12.2.0\dbhome_1\OPatch\opatch apply
Oracle Interim Patch Installer version 12.2.0.1.23
Copyright (c) 2012, Oracle Corporation.  All rights reserved.


Oracle Home       : G:\oracle\product\12.2.0\dbhome_1
Central Inventory : C:\Program Files\Oracle\Inventory
   from           : n/a
OPatch version    : 12.2.0.1.23
OUI version       : 12.2.0.1.0
Log file location : G:\oracle\product\12.2.0\dbhome_1\cfgtoollogs\opatch\31654782_Jul_12_2020_17_47_25\apply2020-07-12_17-47-24PM_1.log

Applying interim patch '31654782' to OH 'G:\oracle\product\12.2.0\dbhome_1'
Verifying environment and performing prerequisite checks...
OiiolLogger.addFileHandler:Error while adding file handler - C:\Program Files\Oracle\Inventory/logs\OPatch2020-07-12_05-47-32-PM.log
java.io.FileNotFoundException: C:\Program Files\Oracle\Inventory\logs\OPatch2020-07-12_05-47-32-PM.log (Access is denied)
Unable to lock Central Inventory.  OPatch will attempt to re-lock.
Do you want to proceed? [y|n]
n
User Responded with: N
Unable to lock Central Inventory.  Stop trying per user-request?
OPatchSession cannot load inventory for the given Oracle Home G:\oracle\product\12.2.0\dbhome_1. Possible causes are:
   No read or write permission to ORACLE_HOME/.patch_storage
   Central Inventory is locked by another OUI instance
   No read permission to Central Inventory
   The lock file exists in ORACLE_HOME/.patch_storage
   The Oracle Home does not exist in Central Inventory

OPatch failed: ApplySession failed to prepare the system. Unable to lock Central Inventory.  Stop trying per user-request?
Log file location: G:\oracle\product\12.2.0\dbhome_1\cfgtoollogs\opatch\31654782_Jul_12_2020_17_47_25\apply2020-07-12_17-47-24PM_1.log

OPatch failed with error code = 22



SOLUTION
~~~~~~~~~~~~~~~~~~~~
Due to Windows security, OPatch must run in a command window that was opened As Administrator
Open cmd.exe As Administrator
Apply or rollback patch

 




Sunday, December 13, 2020

AUTHENTICATION SERVICES Parameter in SQLNET file of Oracle

 

AUTHENTICATION SERVICES Parameter in SQLNET file of Oracle

Authentication Service parameter is used to list the authentication method of connectivity with oracle database.

SQLNET.AUTHENTICATION_SERVICES value all the server attempts to authenticate using each of the following methods.

Note: NTS means OS authenticated and NONE value means password file authenticated.

Authentication Method available in Oracle:
NONE for no authentication method. When parameter is set to none, a valid user name and password can be used to access the database.
ALL for all authentication methods. Default value is all.
BEQ for native operating system authentication for operating systems other than Microsoft Windows
KERBEROS5 for Kerberos authentication
NTS for Microsoft Windows native operating system authentication. Used to connect with OS Authentication.
RADIUS for Remote Authentication Dial-In User Service (RADIUS) authentication
TCPS for SSL authentication

DEFAULT VALUE

SQLNET.AUTHENTICATION_SERVICES = ALL

Example of windows Server

1. Value for SQLNET.AUTHENTICATION_SERVICES is NTS.

SQLNET.AUTHENTICATION_SERVICES = (NTS)

2. Try to connect with SQLPLUS with OS User then its connected.

C:\Users\e3019447>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jun 12 14:26:38 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
SQL>

3. Change the value of parameter to NONE.

SQLNET.AUTHENTICATION_SERVICES = (NONE)

4. It will give the permission error while tried to connect again with OS user.

C:\Users\e3019447>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Tue Jun 12 14:26:58 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-01031: insufficient privileges






Thursday, December 10, 2020

Database Upgrade Failed Due to ORA-04045: errors during recompilation/revalidation of DDL_TRIGGER

 Database Upgrade Failed Due to ORA-04045: errors during recompilation/revalidation of DDL_TRIGGER (Doc ID 2423932.1)


SYMPTOMS

Oracle Database Upgrade Failed with below Error :- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ORA-04045: errors during recompilation/revalidation of LOG_AND_BLOCK_DDL_TRIGGER

ORA-01031: insufficient privileges

ORA-06512: at “SYS.DBMS_UTILITY”,line 1283

ORA-06512: at line 20

LOG_AND_BLOCK_DDL_TRIGGER ORA-01031: insufficient privileges

ORA-06512 : at “SYS.DBMS_UTILITY”, line 1283

ORA-06512: at line 20

ORA-01031: insufficient privileges ORA-06512: at “SYS.DBMS_UTILITY”, line 1283

ORA-06512: at line 20

ORA-06512: at “SYS.DBMS_UTILITY”, line 1283 ORA-06512: at line 20

ORA-06512: at line 20


 


  


CHANGES

 Database Upgrade from 11.2.0.4 to 12.2.0.1


CAUSE

Privileges Issue for system User


05:58:36 SQL> declare

05:58:36 2 cursor ora_dict_synonyms is

05:58:36 3 select o.object_id from dba_objects o

05:58:36 4 where o.owner = ‘PUBLIC’

05:58:36 5 and o.object_type = ‘SYNONYM’

05:58:36 6 and o.object_name like ‘ORA_%’;

05:58:36 7

05:58:36 8 cursor ddl_triggers is

05:58:36 9 select o.object_id from dba_triggers t, dba_objects o

05:58:36 10 where t.owner = o.owner and t.trigger_name = o.object_name

05:58:36 11 and o.object_type = ‘TRIGGER’

05:58:36 12 and (t.triggering_event like ‘%ALTER%’ or

05:58:36 13 t.triggering_event like ‘ÝL%’);

05:58:36 14 begin

05:58:36 15 for s in ora_dict_synonyms loop

05:58:36 16 dbms_utility.validate(s.object_id);

05:58:36 17 end loop;

05:58:36 18

05:58:36 19 for t in ddl_triggers loop

05:58:36 20 dbms_utility.validate(t.object_id);

05:58:36 21 end loop;

05:58:36 22 end;

05:58:36 23 /

declare

*

ERROR at line 1:

ORA-04045: errors during recompilation/revalidation of  DDL_TRIGGER

ORA-01031: insufficient privileges

ORA-06512: at “SYS.DBMS_UTILITY”, line 1283

ORA-06512: at line 20

 


SOLUTION

 


The upgrade documents precisely states below in the section "Requirements and recommendations for Source database"

"Disable any custom triggers that would fire before/after DDL and enable them after the upgrade is complete."


It is strongly recommended to abide by the pre-upgrade tasks as mentioned in the upgrade document.


 


TRIGGERS Should be disabled Prior to Upgrade.


1. We should disable all the triggers before staring the upgrade


To Disable :-

~~~~~~~~~~~~~~

SQL> SELECT ‘ALTER TRIGGER ‘ || owner || ‘.’ || trigger_name || ‘ DISABLE;’ “ALTER Statement” FROM dba_triggers where TRIGGER_TYPE in (‘BEFORE EVENT’,’AFTER EVENT’,’AFTER STATEMENT’);

Example :-


alter trigger XXXXXXXXX disable;



To Enable:-

~~~~~~~~~~~~~

SQL> SELECT ‘ALTER TRIGGER ‘ || owner || ‘.’ || trigger_name || ‘ ENABLE;’ “ALTER Statement” FROM dba_triggers where TRIGGER_TYPE in (‘BEFORE EVENT’,’AFTER EVENT’,’AFTER STATEMENT’);

Example :- 


alter trigger XXXXXXXXX ENABLE;

Or





2. Provide below Privileged


SQL> GRANT ADMINISTER DATABASE TRIGGER to <USER>;

Prior to upgrade to restart the Upgrade .

or you can retry to continue the upgrade




Refer also (Doc ID 2423932.1) for more information










Wednesday, December 9, 2020

How to check Oracle is Standard or Enterprise Edition?

 

How to check Oracle 10/11g is Standard or Enterprise Edition?


In normal situation, we can check the edition of Oracle 10/11g using SQLPlus. Just login using SQLPlus, and there will be a connection message on top of the SQL prompt, stating that the Oracle is either Standard or Enterprise.

Or you can also issue the following select statement to get the edition information:

1
select * from v$version;



However if the database is not created using Database Configuration Assistant (DBCA), but using script or SQL statement, the two methods stated above might not work. It still will show out the edition detail but not stating that it is either Standard or Enterprise.

In such scenario, we will need to dig into the files. In case of Oracle 10g you have to locate the following file:

1
$ORACLE_HOME/inventory/Components21/oracle.server/*/context.xml

Inside this context.xml file, 

check the parameter s_serverInstallType and check out its value (VAL). 

If it is EE, means it is Enterprise Edition. 

         SE or STD means Standard Edition.


In case of Oracle 11g, you need to locate the following file:

1
$ORACLE_HOME/inventory/globalvariables/oracle.server/globalvariables.xml

Inside this globalvariables.xml file, look for variable oracle_install_db_InstallType or oracle_install_db_Installedition 

and check out its value (VALUE). 

If it is EE, means it is Enterprise Edition. 

         SE or STD means Standard Edition.




Monday, December 7, 2020

BSLN_MAINTAIN_STATS_JOB

 BSLN_MAINTAIN_STATS_JOB


ORACLE Defined automatic moving window baseline statistics computation job


ORA-12012: error on auto execute of job “SYS”.”BSLN_MAINTAIN_STATS_JOB”
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at “DBSNMP.BSLN_INTERNAL”, line 2073
ORA-06512: at line 1

Resolution : — Login as sys user.

SQL> sqlplus / as sysdba
— Drop the DBSNMP user by executing catnsnmp.sql script.
SQL> @$ORACLE_HOME/rdbms/admin/catnsnmp.sql
— Create the DBSNMP user by executing catsnmp.sql
SQL> @$ORACLE_HOME/rdbms/admin/catsnmp.sql |

Why do we need this Job

BSLN_MAINTAIN_STATS_JOB  gathers BASELINE “PERFORMANCE” statistics ( waits , etc) used for monitoring the database performance. 
Baselining is a new concept in 11g  which introduces “automatic moving window” during which the performance statistcs are computed.

Disabling that job will stop the moving window baseline from being maintained. 
That’s kind-of important in 11g as a bunch of the automated tuning stuff uses that information. 
If this baseline is not progressed it will not reflect the current usage of your system.



To check the BASELINE DETAILS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SQL> select JOB_NAME,ENABLED,LAST_START_DATE,NEXT_RUN_DATE from dba_scheduler_jobs;

JOB_NAME ENABL LAST_START_DATE NEXT_RUN_DATE
——————————————————————————
AUTO_SPACE_ADVISOR_JOB FALSE 30-JUN-10 11.00.34.034314 AM +08:00
GATHER_STATS_JOB FALSE
FGR$AUTOPURGE_JOB FALSE
PURGE_LOG TRUE 24-MAR-13 03.00.00.332822 AM US/CENTRAL 25-MAR-13 03.00.00.500000 AM US/CENTRAL
SM$CLEAN_AUTO_SPLIT_MERGE TRUE 25-MAR-13 12.00.00.783180 AM +08:00 26-MAR-13 12.00.00.800000 AM +08:00
RSE$CLEAN_RECOVERABLE_SCRIPT TRUE 25-MAR-13 12.00.00.587977 AM +08:00 26-MAR-13 12.00.00.600000 AM +08:00
BSLN_MAINTAIN_STATS_JOB FALSE 24-MAR-13 12.00.00.949599 AM +08:00 31-MAR-13 12.00.00.000000 AM +08:00
DRA_REEVALUATE_OPEN_FAILURES TRUE 24-MAR-13 06.00.02.222367 AM +08:00
ORA$AUTOTASK_CLEAN TRUE 25-MAR-13 03.00.00.220585 AM +08:00 26-MAR-13 03.00.00.300000 AM +08:00
HM_CREATE_OFFLINE_DICTIONARY FALSE
FILE_WATCHER FALSE
MGMT_CONFIG_JOB FALSE
MGMT_STATS_CONFIG_JOB FALSE 01-MAR-11 01.01.01.300000 AM +08:00

13 rows selected.




SQL> select log_date,status from dba_scheduler_job_run_details where job_name=’BSLN_MAINTAIN_STATS_JOB’;

LOG_DATE STATUS
————————————————————————— ——————————
17-MAR-13 12.00.33.954713 AM +08:00 SUCCEEDED
24-MAR-13 12.00.01.458464 AM +08:00 SUCCEEDED
03-MAR-13 12.00.33.502308 AM +08:00 SUCCEEDED
10-MAR-13 12.00.01.042798 AM +08:00 SUCCEEDED



SQL> select * from DBSNMP.BSLN_BASELINES;

DBID INSTANCE_NAME BASELINE_ID BSLN_GUID TI A STATUS LAST_COMPUTE_DA
———- —————- ———– ——————————– — – —————- —————
797835917 EAX 0 13B416E24D693ED2847D9D51D3E22BDF HX Y ACTIVE 17-MAR-13

enable/disable/run the job

exec dbms_scheduler.run_job(‘BSLN_MAINTAIN_STATS_JOB’,false);

exec dbms_scheduler.disable(‘BSLN_MAINTAIN_STATS_JOB’);

exec dbms_scheduler.enable(‘BSLN_MAINTAIN_STATS_JOB’);


Sunday, December 6, 2020

Oracle Binaries installation failed with Error in CreateOUIProcess(): 13 : Permission denied

 

Oracle Binaries  installation failed with Error in CreateOUIProcess(): 13 : Permission denied 


Error in CreateOUIProcess(): 13 : Permission denied”


CAUSE
~~~~~~~~~~

/tmp directory is mounted with noexec option.


You can verify this with following command:

mount
on /tmp type ext3 (rw,noexec,nosuid,nodev)

SOLUTION
~~~~~~~~~~~~~
1) Consult your System Administrator and Remove “noexec” on /tmp folder
For example, to temporarily disable the noexec flag:

mount -o remount,exec /tmp
 or

2) Redirect temp directory to other location which has exec and later retry installation 

Example-

export TMP=/u01/oracle
export TMPDIR=$TMP



Oracle support reference document (Doc ID 1671840.1)



Query to check Table locks history

 select max(sample_time) last_block_time
from gv$active_session_history
--Or use this table for further back.
--from dba_hist_active_sess_history
where blocking_session is not null
    and current_obj# =
    (
        select object_id
        from dba_objects
        where owner = 'JHELLER'       --Enter the object owner here.
            and object_name = 'TEST1' --Enter the object name here.
    );




set pagesize 50
set linesize 120
col sql_id format a15
col inst_id format '9'
col sql_text format a50
col module format a10
col blocker_ses format '999999'
col blocker_ser format '999999'

SELECT  distinct a.sql_id ,a.inst_id,a.blocking_session,a.blocking_session_serial#,a.user_id,s.sql_text,a.module
FROM  GV$ACTIVE_SESSION_HISTORY a  ,gv$sql s
where a.sql_id=s.sql_id
and blocking_session is not null
and a.user_id <> 0 —-  exclude SYS user
-- and a.sample_time > sysdate – 7

SELECT  distinct a.sql_id, a.blocking_session,a.blocking_session_serial#,
a.user_id,s.sql_text,a.module
FROM  V$ACTIVE_SESSION_HISTORY a, v$sql s
where a.sql_id=s.sql_id
and blocking_session is not null
and a.user_id <> 0
and a.sample_time between to_date('17/06/2011 00:00', 'dd/mm/yyyy hh24:mi')

and to_date('17/06/2011 23:50', 'dd/mm/yyyy hh24:mi');




Check Table Lock History information using v$active_session_history:



 Lock History information – v$active_session_history:
====================================================
SELECT LEVEL,
sample_time,
session_id  blocked_sid,
connect_by_root blocking_session ultimate_blocker_sid,
Sys_connect_by_path(blocking_session, ‘/’)
|| ‘/’
|| session_id  blocking_path
FROM   (— Blocked Sessions
SELECT s.session_id,
s.blocking_session,
s.sample_time
FROM   v$active_session_history s
–s.dbid = 70854992
— AND s.instance_number = 1
–AND s.snap_id BETWEEN 62234 and 62235
WHERE  s.blocking_session IS NOT NULL
AND s.event IN ( ‘enq: TX – row lock contention’ )
UNION
— Blocking Sessions
SELECT s.session_id,
s.blocking_session,
s.sample_time
FROM   v$active_session_history s
— s.dbid =
–AND s.instance_number = 1
–AND s.snap_id BETWEEN 622 and 629
WHERE  s.blocking_session IS NULL
AND s.event IN ( ‘enq: TX – row lock contention’,
‘enq: TM – contention’
,
‘enq: UL – contention’,
‘enq: TX – allocate ITL entry’ )
AND EXISTS (SELECT ‘exists’
FROM   v$active_session_history bs
–bs.dbid = 70854992
–AND bs.instance_number = 1
–AND bs.snap_id BETWEEN 622 and 629
WHERE  bs.blocking_session = s.session_id
AND bs.sample_time = s.sample_time
AND bs.blocking_session IS NOT NULL
AND bs.event IN (
‘enq: TX – row lock contention’ )))
CONNECT BY NOCYCLE PRIOR session_id = blocking_session
AND PRIOR sample_time = sample_time
ORDER  BY sample_time; 
========================================================

What we can do, if the required information not found in v$active_session_history?

We can get it from dba_hist_active_sess_history view.

========================================================

SELECT LEVEL,
sample_time,
session_id                       blocked_sid,
connect_by_root blocking_session ultimate_blocker_sid,
Sys_connect_by_path(blocking_session, ‘/’)
|| ‘/’
|| session_id                    blocking_path
FROM   (— Blocked Sessions
SELECT s.session_id,
s.blocking_session,
s.sample_time
FROM   dba_active_sess_history s
— WHERE s.dbid = 70854992
— AND s.instance_number = 1
WHERE  s.snap_id BETWEEN ‘&StSnap’ AND ‘&EdSnap’
AND s.blocking_session IS NOT NULL
AND s.event IN ( ‘enq: TX – row lock contention’,
‘enq: TM – contention’,
‘enq: UL – contention’,
‘enq: TX – allocate ITL entry’ )
UNION
— Blocking Sessions
SELECT s.session_id,
s.blocking_session,
s.sample_time
FROM   dba_active_sess_history s
— s.dbid = 70854992
— s.instance_number = 1
WHERE  s.snap_id BETWEEN ‘&StSnap’ AND ‘&EdSnap’
AND s.blocking_session IS NULL
AND s.event IN ( ‘enq: TX – row lock contention’,
‘enq: TM – contention’
,
‘enq: UL – contention’,
‘enq: TX – allocate ITL entry’ )
AND EXISTS (SELECT ‘exists’
FROM   dba_hist_active_sess_history bs
— bs.dbid = 70854992
— bs.instance_number = 1
WHERE  bs.snap_id BETWEEN ‘&StSnap’ AND ‘&EdSnap’
AND bs.blocking_session = s.session_id
AND bs.sample_time = s.sample_time
AND bs.blocking_session IS NOT NULL
AND bs.event IN (
‘enq: TX – row lock contention’,
‘enq: TM – contention’,
‘enq: UL – contention’,
‘enq: TX – allocate ITL entry’
)))
CONNECT BY NOCYCLE PRIOR session_id = blocking_session
AND PRIOR sample_time = sample_time
ORDER  BY LEVEL DESC,
blocked_sid,

sample_time; 

MATERIALED VIEW --- ANALYZE MVIEWS


 ANALYZE MVIEWS

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  

To analyzes the Materialized View to find out if it can use fast refresh, 

use the DBMS_MVIEW.EXPLAIN_MVIEW procedure which uses table MV_CAPABILITIES_TABLE.


1. Execute utlxmv.sql to create the MV_CAPABILITIES_TABLE .

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You must run the script in the same schema of the materialized view.

SQL> @$ORACLE_HOME/rdbms/admin/utlxmv.sql



2. Execute the DBMS_MVIEW.EXPLAIN_MVIEW procedure using the select statement of create Materialized View.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SQL> EXEC DBMS_MVIEW.EXPLAIN_MVIEW ('<Use SELECT statement of the materialized view >');

Or if you have created the materialized view, use the materialized view name.


SQL> EXEC DBMS_MVIEW.EXPLAIN_MVIEW ('< Materialized view name>');



3. Run the following query to find out if you can use the fast refresh and if not why cen be found in the MSGTXT column.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SQL> set linesize 220

SQL> SELECT SUBSTR(capability_name,1,30)AS capability_name ,  possible, SUBSTR(related_text,1,10)AS related_text,

 SUBSTR(msgtxt,1,90)AS msgtxt FROM MV_CAPABILITIES_TABLE where capability_name like 'REFRESH%'ORDER BY seq;






Example:

~~~~~~~~~~

SQL> @ORACLE_HOME/rdbms/admin/utlxmv.sql

SQL> EXEC DBMS_MVIEW.EXPLAIN_MVIEW ('SELECT * FROM <USER_NAME>.<Table_name>');

SQL> set linesize 220

SQL> SELECT SUBSTR(capability_name,1,30)AS capability_name ,  possible, SUBSTR(related_text,1,10)AS related_text,

 SUBSTR(msgtxt,1,90)AS msgtxt FROM MV_CAPABILITIES_TABLE where capability_name like 'REFRESH%'ORDER BY seq;

 


CAPABILITY_NAME                P RELATED_TEXT     MSGTXT

------------------------------ - --------------- ------------------------------------------------------------------------------------------

REFRESH_COMPLETE               Y

REFRESH_FAST                   N

REFRESH_FAST_AFTER_INSERT      N <USER_NAME>.<Table_name>       the detail table does not have a materialized view log

REFRESH_FAST_AFTER_ONETAB_DML  N                 see the reason why REFRESH_FAST_AFTER_INSERT is disabled

REFRESH_FAST_AFTER_ANY_DML     N                 see the reason why REFRESH_FAST_AFTER_ONETAB_DML is disabled

REFRESH_FAST_PCT               N                 PCT is not possible on any of the detail tables in the materialized view


6 rows selected.




ora-12026 invalid filter column detected in materialized VIEW

 ora-12026 invalid filter column detected



Error code: ORA-12026

Description: invalid filter column detected

Cause: One or more of the specified filter columns did not exist or was a primary key column or a primary key based object identifier.

Action: Ensure that all specified filter columns exist in the master table and ensure that primary key columns or primary key based object identifiers are not included 

        in the list of filter columns.




Solution: Remove the columns other than the PK columns from sequence list

          and DO complete refresh of the MVIEW