Thursday 20 September 2012

ORA-01031: insufficient privileges error


>sqlplus / as sysdba
SQL*Plus: Release 10.1.0.2.0 - Production on Thu Sep 20 10:51:57 2012
Copyright (c) 1982, 2004, Oracle. All rights reserved.
ERROR:
ORA-01031: insufficient privileges



ORA-01031: insufficient privileges error occurs when you attempt to execute a
program or function for which you have not been granted the appropriate privileges.

Solution1 :
Make sure that oracle user is a member of the ORA_DBA group on window and
dba group (e.g. /etc/group) on linux.

 Solution2 : 

If you have already added the oracle user in above group then check have you installed
any other oracle component like owb, in different home then you must have to set the proper environment variable.

verify to connect using complete Path if it connected

>E:\oracle\product\10.2.0\db_1\bin\sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Sep 20 10:53:48 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:

If you are able to connect then set ORACLE_HOME properly

Wednesday 19 September 2012

ORA-00439: feature not enabled: Materialized view rewrite


Check the Materialized view rewrite option is enable or disable

Select * from v$option where lower(parameter) like 'materialized%'

PARAMETER                    VALUE
---------------------             --------------
Materialized view rewrite      FALSE


standard  edition not allow to use the Materialized view Query rewrite option


if you check on EE then you will got the output

SQL> SELECT * FROM v$option WHERE LOWER(parameter) LIKE '%aterialized%';

PARAMETER                                  VALUE 
------------------                              ------------------- 
Materialized view rewrite                        TRUE 
Materialized view warehouse refresh       TRUE  


Clustering Factor and its Effects on Performance

Clustering Factor :

During table blocks reading using index how many switches took place between table blocks is counted as clustering factor.Simply can say If values in the leaf block are in different blocks in the table, then the clustering factor is incremented by one.



 i.e if a given index leaf block have five entires and in tables these entires are separated over 4 blocks then block switches are
four.and if exists in single block then clustering factor is 1.

Effects on performance :

CBO calculate the costing on the basis of the clustering factor hence its directly influence the performance.


If clustering rector is poor :-

1)  More data blocks read More disk I/O
2)  Tables are flush quickly from the buffer pool because a relatively large number
     of blocks has to be read in buffer pool

How can Reduce the Clustering factor:- 

In below example shown if the index is created on pre-sorted value the clustering factor can be reduce hugely:


SQL> create table test_tables as select * from dba_tables;

Table created.

SQL> create index test_index on test_tables(table_name);

Index created.

We can calculate the clustring fector from  clustering_factor.user_indexes 


SQL>  select clustering_factor from user_indexes where index_name='TEST_INDEX'

CLUSTERING_FACTOR
-----------------
654

Check the number of rows in table

SQL> select count(*) from test_tables;

COUNT(*)
----------
1585

Find the rows are distributed in houw many blocks


SQL>  select blocks from user_segments where segment_name='TEST_TABLES'

BLOCKS
----------
56

In above example 1585 rows are distributed in 56 blocks and clustering factor is 654.

Now we insert the data in sorted form in the column in which we have to create the index

SQL> create table test_tables_o as select * from dba_tables order by table_name;

Table created.

SQL> create index test_index_o on test_tables_o(table_name);

Index created.

Calculate the clustering factor it becomes 48 and number of rows and blocks are same

SQL> select clustering_factor from user_indexes where index_name='TEST_INDEX_O';

CLUSTERING_FACTOR
-----------------
48

SQL> select count(*) from test_tables_o;

COUNT(*)
----------
1586

SQL> select blocks from user_segments where segment_name='TEST_TABLES';

BLOCKS
----------
56



Tuesday 18 September 2012

PLS-00201: identifier 'DBMS_SHARED_POOL.PURGE' must be declared

I wanted to flush the single sql from shared pool and i have fire the below statement but got the below error:


SQL> EXECUTE DBMS_SHARED_POOL.PURGE ('000000053F872000, 2083103143', 'C');
BEGIN DBMS_SHARED_POOL.PURGE ('000000053F872000, 2083103143', 'C'); END;

*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_SHARED_POOL.PURGE' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored



to declare the DBMS_SHARED_POOL.PURGE you have to run dbmspool.sql under ORACLE_HOME/rdbms/admin/directory



SQL> ?/rdbms/admin/dbmspool.sql
SP2-0172: No HELP matching this topic was found.
SQL> @?/rdbms/admin/dbmspool.sql

Package created.


Grant succeeded.


View created.


Package body created.

SQL> EXECUTE DBMS_SHARED_POOL.PURGE ('000000053F872000, 2083103143', 'C');

PL/SQL procedure successfully completed.

oracle 11g uninstall error Please run the command .............




I have started the OUI and select the unistall option for oracle 11g home and got below error:





You need to be expand the oracle home menu and have to select submenu  as given below it the screen shot:

After that run installer will run properly 



Monday 17 September 2012

File not found ......opatch.ini at the time oracle 11gR2 installation

When we try to install oracle 11gR2 simply by unzip win32_11gR2_database_1of2.zip and win32_11gR2_database_2of2.zip .Then we got an  error given below



Solution 


Window:

copy the files from  \database\stage\Components to the folder  \win32_11gR2_database_2of2\database\stage\Components\


Linux\Unix

Unzip the 11g software in same directory

gunzip   win32_11gR2_database_1of2.zip -d /home/oracle
gunzip   win32_11gR2_database_2of2.zip  -d  /home/oracle




Friday 14 September 2012

How to bring a datafile ONLINE as it is in RECOVER mode because it was OFFLINE(ORA-01113: )

I want  to bring the datafile online but got below error :


SQL> alter database datafile '/home/oracle/oradaata/tbs01.dbf' online;
alter database datafile '/home/oracle/oradaata/tbs01.dbf' online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/home/oracle/oradaata/tbs01.dbf'


I have checked the (status.dba_data_files) then found it's in recover mode
instead it should be in offline mode as DBA have switched it to offline mode earlier

This is due to DBA have not performed the manual checkpoint before switched it to offline .

Solution:

Not need to restore the datafile as it in place.If you have lost your datafile or corupted then only you need to be restore the datafile

Here only needs those ArchiveLogs thatcaptured the Checkpoint of the Datafile and it's being taken OFFLINE

step 1 :

SQL> recover datafile 5;

ORA-00279: change 718137 generated at 12/05/2012 15:32:56 needed for thread 1
ORA-00289: suggestion : archs/1_09.dbf
ORA-00280: change 718137 for thread 1 is in sequence #11714

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/archs/1_11714_785958283.dbf
ORA-00279: change 718252 generated at 12/05/2012 15:33:01 needed for thread 1
ORA-00289: suggestion : archs/1_10.dbf
ORA-00280: change 718252 for thread 1 is in sequence #11715

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/archs/1_11715_785958283.dbf
Log applied.
Media recovery complete.
SQL>

SQL> alter database datafile '/home/oracle/oradaata/tbs01.dbf' online;

Database alterd.

How do I reclaim space held by temporary segments in Oracle

Data being loading using direct path I was in the process of dropping a
table when the instance crashed! I now have a bunch of TEMP segments in the tablespace.
How do I reclaim space held by temporary segments in Oracle?

SQL> select segment_name ,segment_type from dba_segments where tablespace_name='TBS1!' ;

SEGMENT_NAME SEGMENT_TYPE
7.45678 Temporaray

you need to be use a drop segments event to remove temporary space from a tablespace:

First find the TS# value for the above tablespace

select TS# from v$tablespace where name='TBS1';
TS#
----
5

Then fire the event given below

ALTER SESSION SET EVENTS 'immediate trace name drop_segments level $a ';
where: a is the value for ts$ plus 1 here it would be 6:

SQL> select segment_name ,segment_type from dba_segments where tablespace_name='TBS1!' ;
no row selected


ORA-07445: exception encountered: core dump [skgfr_reap64()+235] [SIGSEGV] [Address not mapped to object] [0x2AEE7443A188] [] []


In the database alert log there is continuous message "WARNING: Oracle process running out of OS kernel I/O resources". In the trace file you will notice following message.
WARNING:io_submit failed due to kernel limitations MAXAIO for process=128 pending aio=81
WARNING:asynch I/O kernel limits is set at AIO-MAX-NR=1048576 AIO-NR=67968
WARNING:Oracle process running out of OS kernel I/O resources

Cause of the Problem
This is Oracle bug. Oracle named this bug as Bug 6687381 or Bug 7523755. This problem only occurs on platforms where the kernel cannot dynamically allocate Async IO descriptors.

Solution of the Problem
Workaround you can disable the asynchronous IO by setting disk_asynch_io to FALSE but that is not recommended because if disk_asynch_io=FALSE, then asynchronous I/O is not enabled, which may have a detrimental effect on performance.

This bug is fixed in following versions.
- 11.1.0.7 (Server Patch Set)
- 10.2.0.5 (Server Patch Set)
- 10.2.0.4.2 (Patch Set Update)
- 10.2.0.4 Patch 26 on Windows Platforms
- 11.2g

So upgrading to your oracle database is the viable solution.