Total Pageviews

Monday, 25 June 2012

PFILE vs SPFILE

When an Oracle Instance is started, the characteristics of the Instance are established by parameters specified within the initialization parameter file. These initialization parameters are either stored in a PFILE or SPFILE. SPFILEs are available in Oracle 9i and above. All prior releases of Oracle are using PFILEs.

SPFILEs provide the following advantages over PFILEs:
  • An SPFILE can be backed-up with RMAN (RMAN cannot backup PFILEs)
  • The SPFILE is maintained by the server. Parameters are checked before changes are accepted.
  • Eliminate configuration problems (no need to have a local PFILE if you want to start Oracle from a remote machine)
  • Easy to find - stored in a central location
What is the difference between a PFILE and SPFILE:

A PFILE is a static, client-side text file that must be updated with a standard text editor like "notepad" or "vi". This file normally reside on the server, however, you need a local copy if you want to start Oracle from a remote machine. DBA's commonly refer to this file as the INIT.ORA file.

An SPFILE (Server Parameter File), on the other hand, is a persistent server-side binary file that can only be modified with the "ALTER SYSTEM SET" command. This means you no longer need a local copy of the pfile to start the database from a remote machine. Editing an SPFILE will corrupt it, and you will not be able to start your database anymore.

How will I know if my database is using a PFILE or SPFILE:

Execute the following query to see if your database was started with a PFILE or SPFILE:

SQL> SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type"
FROM sys.v_$parameter WHERE name = 'spfile';

You can also use the V$SPPARAMETER view to check if you are using a PFILE or not: if the "value" column is NULL for all parameters, you are using a PFILE.

Starting a database with a PFILE or SPFILE:

Oracle searches for a suitable initialization parameter file in the following order:
Try to use the spfile${ORACLE_SID}.ora file in $ORACLE_HOME/dbs (Unix) or ORACLE_HOME/database (Windows)
Try to use the spfile.ora file in $ORACLE_HOME/dbs (Unix) or ORACLE_HOME/database (Windows)
Try to use the init${ORACLE_SID}.ora file in $ORACLE_HOME/dbs (Unix) or ORACLE_HOME/database (Windows)

One can override the default location by specifying the PFILE parameter at database startup:

SQL> STARTUP PFILE='/oradata/spfileORCL.ora'

Note that there is not an equivalent "STARTUP SPFILE=" command. One can only use the above option with SPFILE's if the PFILE you point to (in the example above), contains a single 'SPFILE=' parameter pointing to the SPFILE that should be used. Example:

SPFILE=/path/to/spfile

Changing SPFILE parameter values:

While a PFILE can be edited with any text editor, the SPFILE is a binary file. The "ALTER SYSTEM SET" and "ALTER SYSTEM RESET" commands can be used to change parameter values in an SPFILE. Look at these examples:

SQL> ALTER SYSTEM SET open_cursors=300 SCOPE=SPFILE;

SQL> ALTER SYSTEM SET timed_statistics=TRUE
COMMENT='Changed by Frank on 1 June 2003'
SCOPE=BOTH
SID='*';

The SCOPE parameter can be set to SPFILE, MEMORY or BOTH:


- MEMORY: Set for the current instance only. This is the default behaviour if a PFILE was used at STARTUP.

- SPFILE: update the SPFILE, the parameter will take effect with next database startup

- BOTH: affect the current instance and persist to the SPFILE. This is the default behaviour if an SPFILE was used at STARTUP.
The COMMENT parameter (optional) specifies a user remark.

The SID parameter (optional; only used with RAC) indicates the instance for which the parameter applies (Default is *: all Instances).

Use the following syntax to set parameters that take multiple (a list of) values:


SQL> ALTER SYSTEM SET utl_file_dir='/tmp/','/oradata','/home/' SCOPE=SPFILE;

Use this syntax to set unsupported initialization parameters (obviously only when Oracle Support instructs you to set it):

SQL> ALTER SYSTEM SET "_allow_read_only_corruption"=TRUE SCOPE=SPFILE;

Execute one of the following command to remove a parameter from the SPFILE:

SQL> ALTER SYSTEM RESET timed_statistics SCOPE=SPFILE SID=‘*’;
SQL> ALTER SYSTEM SET timed_statistics = '' SCOPE=SPFILE;

Converting between PFILES and SPFILES:


One can easily migrate from a PFILE to SPFILE or vice versa. Execute the following commands from a user with SYSDBA or SYSOPER privileges:

SQL> CREATE PFILE FROM SPFILE;
SQL> CREATE SPFILE FROM PFILE;

One can also specify a non-default location for either (or both) the PFILE and SPFILE parameters. Look at this example:

SQL> CREATE SPFILE='/oradata/spfileORCL.ora' from PFILE='/oradata/initORCL.ora';

Here is an alternative procedure for changing SPFILE parameter values using the above method:
Export the SPFILE with: CREATE PFILE=‘pfilename’ FROM SPFILE = ‘spfilename’;
Edit the resulting PFILE with a text editor
Shutdown and startup the database with the PFILE option: STARTUP PFILE=filename
Recreate the SPFILE with: CREATE SPFILE=‘spfilename’ FROM PFILE=‘pfilename’;
On the next startup, use STARTUP without the PFILE parameter and the new SPFILE will be used.

Parameter File Backups:

RMAN (Oracle's Recovery Manager) will backup the SPFILE with the database control file if setting "CONFIGURE CONTROLFILE AUTOBACKUP" is ON (the default is OFF). PFILEs cannot be backed-up with RMAN. Look at this example:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

Use the following RMAN command to restore an SPFILE:

RMAN> RESTORE CONTROLFILE FROM AUTOBACKUP;

Tuesday, 19 June 2012

[Error]: 10g component 'SET_NO_OUTLINES' must be declared

IMP-00058: ORACLE error 6550 encountered
ORA-06550: line 1, column 33:
PLS-00302: component 'SET_NO_OUTLINES' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
IMP-00000: Import terminated unsuccessfully


This error was encountered when exporting from a 9i database using a 10g client, and then importing into a 9i databse using the 10g client. I had to export and import using the 9i client in the end.
If you are using Windows, type PATH at the command prompt and see what the values are set to. There will most likely be multiple Oracle paths in there, for example D:\Oracle\Ora92 and D:\Oracle\product\10.2.0\db_1. The one which appears first will take priority over the others.
You can modify which appears first on your command prompt session by copying out the path to a text file, re-arranging it so that either the 9i or 10g one appears first and then copy it back into your command prompt window, with a PATH=D:\Oracle\Ora92.....etc, etc.
You can also modify this parameter for the environment by going to START -> right click My Computer -> Advanced -> Environment Variables -> In the System Variables box there is a PATH variable. Change the order of that.
If you are still unsure, you can also specify the full path whenever you invoke SQLPlus orIMP/EXP, etc. For example, my PATH variable has has D:\Oracle\Ora92 at the beginning of it but I want to use the 10g Export command. I would type D:\Oracle\Product\10.2.0\db_1\BIN\EXP to invoke the export command.  

Saturday, 9 June 2012

Find IP Address @Linux Machine

[oracle@sumit-server ~]$ /sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:21:91:79:90:F6
 inet addr:192.168.46.31 Bcast:192.168.4.255 Mask:255.255.255.0
  inet6 addr: fe85::261:91ff:fe79:90f6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
  RX packets:870754 errors:0 dropped:0 overruns:0 frame:0
  TX packets:104870 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
  RX bytes:1839451948 (175.4 MiB) TX bytes:9954219 (9.4 MiB)
Interrupt:193 Base address:0xe000

Wednesday, 6 June 2012

ORA-07445: exception encountered: core dump [ACCESS_VIOLATION]

Alert log Entry :

Restarting dead background process MMON
MMON started with pid=15, OS id=5112
Tue Jun 05 20:59:37 2012
Errors in file d:\oracle\product\10.2.0\admin\saas\bdump\saas_mmon_5112.trc:
ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [_keltfill+86] [PC:0xBA78BA] [ADDR:0x0] [UNABLE_TO_READ] []

Solution: 

SQL>Alter system set "_threshold_alerts_enable" = 0 scope = spfile sid = '*'; 

Restart the database followed by Machine restart.





Friday, 1 June 2012

ORA-00600 :[QKACON:FJswrwo]

Error code: Internal error code ORA-00600 [QKACON:FJswrwo],[3],[],[],[],[],[] occurs with connect by is an internal oracle error.
If this error occurs be alert you have only approx 20 Minutes to respond or ur DB can crash.

Solutions:
1.Upgrade to 11.1.0.6 or higher as this internal bug has been  fixed by oracle in version  11.1.0.6.

2.Try the below workarounds:(As recommended by Oracle support)

a) SET  the hidden parameter "_optimizer_connect_by_cost_based" = false;
  • SQL>Alter session set  "_optimizer_connect_by_cost_based" = false;
or
b)Disable Hash Join:
  • Alter session set "_hash_join_enabled"=false;
  • Alter session set "_right_outer_hash_enable"=false;
  • Alter session set "_gby_hash_aggregation_enabled"=false;

My prob got resolved using the workaround :  "_optimizer_connect_by_cost_based" = false;

To check the values of hidden parameters you can use the below Query:

SELECT x.inst_id,x.indx+1,ksppinm,ksppity,ksppstvl,ksppstdf,
DECODE(BITAND(ksppiflg/256,1),1,'TRUE','FALSE'),
DECODE(BITAND(ksppiflg/65536,3),1,'IMMEDIATE',2,'DEFERRED',3,'IMMEDIATE','FALSE'),
DECODE(BITAND(ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE'),
DECODE(BITAND(ksppstvf,2),2,'TRUE','FALSE'),
ksppdesc
FROM x$ksppi x,
x$ksppcv y
WHERE (x.indx = y.indx)
/*and (translate(ksppinm,'_','#') not like '#%'
OR (TRANSLATE(ksppinm,'_','#') LIKE '#%'AND ksppstdf = 'TRUE'))*/
ORDER BY 3;

Below you can find the list of some useful oracle hidden params:


Parameter Name
Details
_B_TREE_BITMAP_PLANS
This parameter’s default value changed from FALSE in Oracle 8i to TRUE in Oracle 9i.

This can lead to an undesirable impact on performance thus this should be set to FALSE.
_INDEX_JOIN_ENABLED
This parameter’s default value changed from FALSE in Oracle 8i to TRUE in Oracle 9i.

This can lead to an undesirable impact on performance thus this should be set to FALSE.
_KGL_LARGE_HEAP_WARNING_THRESHOLD
This parameter was introduced in 10G Release 2.  This will eliminate the following error message:
Memory Notification: Library Cache Object loaded into SGA
Heap size XXXXK exceeds notification threshold

For example set it as follows:

ALTER SYSTEM SET "_KGL_LARGE_HEAP_WARNING_THRESHOLD" = 8388608 SCOPE = SPFILE;
QUERY_REWRITE_ENABLED
In order to make use of the Function Based Indexes this parameter must be set to TRUE.
OPTIMIZER_SECURE_VIEW_MERGING
This parameter was introduced in 10G Release 2.  Setting this parameter to FALSE is required otherwise it is possible for the optimizer to create different execution plans for identical statements on identical objects issued from different user schemas.
_OPTIMIZER_CONNECT_BY_COST_BASED
Setting this parameter to FALSE is required for a workaround to the Oracle error ORA-600 [qkacon:FJswrwo].

Wednesday, 30 May 2012

Move or Rename the Tempfile in Oracle


#####  Move tempfile from location  ‘/sumit04/data01/sumit04/temp01.dbf’ to ‘/sumit04/data03/sumit04/temp01.dbf’  #####

SQL> SELECT v.file#, t.file_name, v.status from dba_temp_files t, v$tempfile v WHERE t.file_id = v.file#;
FILE#  FILE_NAME STATUS
-----------------------------------------------
 1  /sumit04/data01/sumit04/temp01.dbf  ONLINE
 2 /sumit04/data02/sumit04/temp02.dbf   ONLINE

SQL> ALTER DATABASE TEMPFILE '/sumit04/data01/sumit04/temp01.dbf' OFFLINE;

Database altered.

SQL> SELECT v.file#, t.file_name, v.status from dba_temp_files t, v$tempfile v WHERE t.file_id = v.file#;
 FILE# FILE_NAME STATUS
----------------------------------------------------
 1 /sumit04/data01/sumit04/temp01.dbf  OFFLINE
 2 /sumit04/data02/sumit04/temp02.dbf  ONLINE

#Copy the old temp files to other location(/data03):

SQL> !cp -p /sumit04/data01/sumit04/temp01.dbf /sumit04/data03/sumit04/temp01.dbf;

SQL> ALTER DATABASE RENAME FILE '/sumit04/data01/sumit04/temp01.dbf' TO '/sumit04/data03/sumit04/temp01.dbf';

Database altered.

SQL> SELECT v.file#, t.file_name, v.status from dba_temp_files t, v$tempfile v WHERE t.file_id = v.file#;
  FILE#   FILE_NAME STATUS
--------------------------------------------------------
  1    /sumit04/data03/sumit04/temp01.dbf OFFLINE
  2   /sumit04/data02/sumit04/temp02.dbf  ONLINE

SQL> ALTER DATABASE TEMPFILE '/sumit04/data03/sumit04/temp01.dbf' ONLINE;

Database altered.

SQL> SELECT v.file#, t.file_name, v.status from dba_temp_files t, v$tempfile v WHERE t.file_id = v.file#;
 FILE# FILE_NAME STATUS
---------------------------------------------------------
 1 /sumit04/data03/sumit04/temp01.dbf   ONLINE
 2 /sumit04/data02/sumit04/temp02.dbf   ONLINE

#Remove the old temp file
SQL> !rm -rf /sumit04/data01/sumit04/temp01.dbf

Tuesday, 29 May 2012

ORA-01041: internal error. hostdef extension doesn't exist

ORA-01041: internal error. hostdef extension doesn"t exist

Cause: Pointer to hstdef extension in hstdef is null.

Action: Report as a bug

If ORA-01041 is thrown, an internal error has occurred in which the pointer to the hstdef extension in hstdef is null.

In Oracle, many times ORA-01041 is thrown after either startup or shutdown. If you are using SQL*Plus, you will have to reconnect to the database or start a new SQL*Plus session. The ORA-01041 has been known to be caused by a bug which des not seem to allow a shutdown immediately followed by a startup in a congruent SQL*Plus session.

To resolve ORA-01041, you should report the error as a bug. In the case of ORA-01041 as a response to performing shutdown and startup, you can use the ipcrm command and remove allocated shared memory segments.

Wednesday, 23 May 2012

To check hidden parameters oracle

SELECT x.inst_id,x.indx+1,ksppinm,ksppity,ksppstvl,ksppstdf,
DECODE(BITAND(ksppiflg/256,1),1,'TRUE','FALSE'),
DECODE(BITAND(ksppiflg/65536,3),1,'IMMEDIATE',2,'DEFERRED',3,'IMMEDIATE','FALSE'),
DECODE(BITAND(ksppstvf,7),1,'MODIFIED',4,'SYSTEM_MOD','FALSE'),
DECODE(BITAND(ksppstvf,2),2,'TRUE','FALSE'),
ksppdesc
FROM x$ksppi x,
x$ksppcv y
WHERE (x.indx = y.indx)
--AND x.indx =1178
/*and (translate(ksppinm,'_','#') not like '#%'
OR (TRANSLATE(ksppinm,'_','#') LIKE '#%'AND ksppstdf = 'TRUE'))*/
ORDER BY 3;

Saturday, 19 May 2012

11G Installation Error " em.ear" is missing


Issue     :  em.ear is missing while installing 11G.

Reason   : The installer could not find the correct files because it was expecting them to be in the one folder and not two different one.
Solution:

windows:
Copy the contents of the components folder into the one components folder, cleaned up the failed install and then re-ran the install operation. This will solve the problem.

Linux:
To unzip the 11g s/w in same directory:

# 11.2.0.1
unzip linux.x64_11gR2_database_1of2.zip -d /home/oracle/softwaredump
unzip linux.x64_11gR2_database_2of2.zip -d /home/oracle/softwaredump

#11.2.0.2
unzip p10098816_112020_Linux-x86-64_1of7.zip -d /home/oracle/softwaredump
unzip p10098816_112020_Linux-x86-64_2of7.zip -d /home/oracle/softwaredump

#11.2.0.3 ##for upgrading patch sets:
unzip p10404530_112030_Linux-x86-64_1of7.zip -d /home/oracle/softwaredump
unzip p10404530_112030_Linux-x86-64_2of7.zip -d /home/oracle/softwaredump


Friday, 18 May 2012

ORA-25153: Temporary Tablespace is Empty

Got the following error today when trying to execute full export backup command:
exp system/sys file=full_exp2.dmp log=full_exp2.log full=y consistent=y statistics=none buffer=10000000
EXP-00008: ORACLE error 25153 encountered
ORA-25153: Temporary Tablespace is Empty
EXP-00083: The previous problem occurred when calling SYS.LT_EXPORT_PKG.system_info_exp
EXP-00008: ORACLE error 25153 encountered
ORA-25153: Temporary Tablespace is Empty
ORA-06512: at "SYS.DBMS_LOB", line 443
ORA-06512: at "SYS.DBMS_SCHED_MAIN_EXPORT", line 571
ORA-06512: at "SYS.DBMS_SCHED_WINDOW_EXPORT", line 14
ORA-06512: at line 1
EXP-00085: The previous problem occurred when calling SYS.DBMS_SCHED_WINDOW_EXPORT.create_exp for object 8879
EXP-00008: ORACLE error 25153 encountered
ORA-25153: Temporary Tablespace is Empty
ORA-06512: at "SYS.DBMS_LOB", line 443
ORA-06512: at "SYS.DBMS_SCHED_MAIN_EXPORT", line 571
ORA-06512: at "SYS.DBMS_SCHED_WINDOW_EXPORT", line 14
ORA-06512: at line 1
EXP-00085: The previous problem occurred when calling SYS.DBMS_SCHED_WINGRP_EXPORT.create_exp for object 8881
. exporting pre-schema procedural objects and actions
. exporting cluster definitions
EXP-00056: ORACLE error 25153 encountered
ORA-25153: Temporary Tablespace is Empty
EXP-00056: ORACLE error 25153 encountered
ORA-25153: Temporary Tablespace is Empty
EXP-00000: Export terminated unsuccessfully

Solution:

First step is to check for temp tablespace and assosiation with users.

select username, temporary_tablespace, account_status from dba_users where username not like '%SYS%';

If  temporary_tablespace exists (TEMP) move to step2 to check datafiles assosiated with the tablespace as below:

Issue No data File associated with temp tablespace:
SQl>Select file_name from dba_temp_files;
No row selected
As you can see there is no data file associated with Temp tablespace;this is the reason of the issue.

To solve the issue simply add a datafile to the temp tablespace using the below command:

SQL>Alter tablespace Temp ADD TEMPFILE '/Data/Oracle4/oradata/new12/MyTemp.dbf' size 500M;

Check again to confirm:(Issue Resolved)
SQl>Select file_name from dba_temp_files;

output:  '/Data/Oracle4/oradata/new12/MyTemp.dbf'