Upload
praveen-gupta
View
94
Download
3
Embed Size (px)
Citation preview
Free Oracle Tips
HTML Text
Search BC Oracle Sites
Home
E-mail Us
Oracle Articles
Oracle Training
Oracle Tips
Oracle Forum
Class Catalog
Remote DBA
Oracle Tuning
Emergency 911
RAC Support
Apps Support
Analysis
Design
Implementation
Oracle Support
SQL Tuning
Security
Oracle UNIX
Oracle Linux
Monitoring
Remote support
Remote plans
Remote services
Application Server
Applications
Oracle Forms
Oracle Portal
App Upgrades
SQL Server
Oracle Concepts
Software Support
Remote Support
Development
Implementation
Consulting Staff
Consulting Prices
Oracle Concepts - pfile and spfileOracle Tips by Burleson Consulting
Introducing the PFILE and SPFILE
Oracle provides two different types of mutually exclusive parameter files that youcan use, PFILE and SPFILE. Let’s look at the PFILE and the SPFILE in a bitmore detail.
The Oracle PFILE
As we said, the parameters are stored in either a PFILE or an SPFILE. ThePFILE is a text-based file, and the “init.ora” file has been around for over adecade. Inside the PFILE are a number of database settings called parameters.These parameters help the Oracle programs know how to start. The parameterstell the Oracle programs how much memory to allocate, where to put files relatedto the database and where certain database files already exist.
As the PFILE is text based, one can edit it in an editor like vi on UNIX orNotepad on Windows. When you have changed it, you need to make sure yousave your changes to disk before you exit the editor. Also, make sure you save itas a plain text file, since some editors (like Microsoft Word) can save documentsin special formats that Oracle would not be able to read.
Depending on which operating system you are running on, your PFILE is locatedby default in the ORACLE_HOME\database (usually the case on Windows) orORACLE_HOME\dbs directory for most other platforms (we talked about whereORACLE_HOME was earlier in this book).
If you are using a PFILE, it takes on the form of initSID.ora, meaning the file willuse the ORACLE_SID you defined when you created the database. If your SIDis called testdb, the resulting PFILE should be called inittestdb.ora
The Oracle SPFILE
The SPFILE is different from the PFILE in that it can not be directly edited. Thisis because it has a header and footer that contains binary values. Since you cannot change a SPFILE directly, Oracle allows you to manage the SPFILE via thealter system command.
That might sound a bit more complex, but it really is no harder than manuallychanging a PFILE. For using an SPFILE, you can reap great benefits. It can bebacked up by RMAN (Oracle’s backup and recovery software) every time achange is made or when the database is backed up, which means it’s easier torecover (we will talk about RMAN a great deal in a later chapter!). Also,SPFILES allow you to make dynamic changes to parameters that are persistent.For example, remember that we said this database parameter change was notpersistent if we were using PFILES:
Alter system set db_recovery_file_dest_size=10g;
If we were using SPFILES the parameter would keep the same value, even after adatabase restart. This means you only have to change the parameter value in one
Oracle Concepts - pfile and spfile http://www.dba-oracle.com/concepts/pfile_spfile.htm
1 of 5 21-07-2011 15:04
Help Wanted!
Oracle Posters
Oracle Books
Oracle Scripts
Ion
Excel-DB
place, and that you can forget having to change it in the PFILE of the database.
One of the most important benefits of the SPFILE is that Oracle has introducedmany automatic tuning features into the core of the database. Without anSPFILE, Oracle can not autotune your database.
An SPFILE uses the same formatting for its file name as the PFILE, except theword spfile replaces init. For instance, if your ORACLE_SID is testdb, theresulting spfile would be called spfiletestdb.ora.
Administering the PFILE and SPFILE
As a DBA the main thing you need to worry about with the SPFILE and PFILESare backing them up. You can use RMAN to backup an SPFILE, or back them upyourself.
Remember that a PFILE is simply a text based file, which means you can copy itto another directory without affecting the Oracle instance. This is the easiest wayto backup a PFILE.
To back up an SPFILE, you will first want to convert it to a PFILE. You can dothis with the following syntax.
SQL> create pfile from spfile;
This will create a PFILE named initSID.ora in your $ORACLE_HOME/database(Windows) or $ORACLE_HOME/dbs (Linux/Unix) directory.
Note that the SID in initSID.ora will be replaced with the SID of your database asdefined during creation.
In addition, you can back up the file directly to the preferred location with thecommand:
SQL> create pfile=/path/to/backup.ora from spfile;
If the time comes that you must put the SPFILE back into place, you can do sowith this command:
SQL> create spfile from pfile=/path/to/backup.ora
If your database is currently running using the SPFILE, be sure to shut down firstso Oracle can replace the file. As your SPFILE is in use the entire time yourdatabase is running, you should never overwrite it during normal operations
You can use the V$PARAMETER dynamic view to see the current setting of thedifferent database parameters. In this example, we use the DESC SQL*Pluscommand to describe the V$PARAMETER view, and we then query theV$PARAMETER view to see the value of the control_file parameter setting:
SQL> desc v$parameter Name Null? Type ----------------------------------------- -------- ------------- NUM NUMBER NAME VARCHAR2(80) TYPE NUMBER VALUE VARCHAR2(512) DISPLAY_VALUE VARCHAR2(512) ISDEFAULT VARCHAR2(9) ISSES_MODIFIABLE VARCHAR2(5) ISSYS_MODIFIABLE VARCHAR2(9) ISINSTANCE_MODIFIABLE VARCHAR2(5) ISMODIFIED VARCHAR2(10) ISADJUSTED VARCHAR2(5) ISDEPRECATED VARCHAR2(5) DESCRIPTION VARCHAR2(255) UPDATE_COMMENT VARCHAR2(255) HASH NUMBER SQL> select name, value from v$parameter where name = 'control_files'; NAME VALUE-------------------- -----------------------------------------------control_files C:\ORACLE\ORADATA\BOOKTST\BOOKTST\CONTROL01.CTL, C:\ORACLE \ORADATA\BOOKTST\BOOKTST\CONTROL02.CTL, C:\ORACLE\ORADATA\ BOOKTST\BOOKTST\CONTROL03.CTL
Oracle training & performance tuning books
Oracle Concepts - pfile and spfile http://www.dba-oracle.com/concepts/pfile_spfile.htm
2 of 5 21-07-2011 15:04
You may also use the shortcut “show parameter” command. For instance:
SQL> show parameter control_files;
The Parameter File at Startup Time
Oracle prefers the use of an SPFILE to a PFILE. When you startup your Oracledatabase, Oracle will scan the contents of your parameter directory($ORACLE_HOME/database on Windows or the Linux directory name$ORACLE_HOME/dbs), searching in the following order:
* spfileSID.ora
* spfile.ora
* initSID.ora
* init.ora
If the directory contains none of the above, then the startup will fail.
Alternatively, you can tell Oracle where to find a PFILE if you store it in adifferent location.
SQL> startup pfile=/path/to/pfile/inittestdb.ora
Furthermore, you can create a PFILE that contains nothing but the following line:
SPFILE=/path/to/spfiletestdb.ora
By doing so, we are able to startup using a PFILE in any location we want, butcontinue to use an SPFILE that can also be in a different location. This can bevery beneficial for those that wish to store their SPFILE in a centralized location,such as a SAN. Now, let’s take a quick look at redo log administration.
This is an excerpt from the bestselling "Easy Oracle Jumpstart" by RobertFreeman and Steve Karam (Oracle ACE and Oracle Certified Master). It’s only$19.95 when you buy it directly from the publisher here.
If you like Oracle tuning, you may enjoy the new book"Oracle Tuning: The Definitive Reference", over 900 pagesof BC's favorite tuning tips & scripts.
You can buy it direct from the publisher for 30%-off andget instant access to the code depot of Oracle tuningscripts.
Oracle Concepts - pfile and spfile http://www.dba-oracle.com/concepts/pfile_spfile.htm
3 of 5 21-07-2011 15:04
Burleson is the American Team
Note: This Oracle documentation was created as a support and Oracle trainingreference for use by our DBA performance tuning consulting professionals. Feel free to ask questions on our Oracle forum.
Verify experience! Anyone considering using the services of an Oracle supportexpert should independently investigate their credentials and experience, andnot rely on advertisements and self-proclaimed expertise. All legitimate Oracleexperts publish their Oracle qualifications.
Errata? Oracle technology is changing and we strive to update our BC Oraclesupport information. If you find an error or have a suggestion for improvingour content, we would appreciate your feedback. Just e-mail:
and include the URL for the page.
Burleson ConsultingThe Oracle of Database Support
Oracle Performance Tuning
Remote DBA Services
Oracle Concepts - pfile and spfile http://www.dba-oracle.com/concepts/pfile_spfile.htm
4 of 5 21-07-2011 15:04
Copyright © 1996 - 2011 by Burleson Enterprises
All rights reserved.
Oracle © is the registered trademark of Oracle Corporation.
Oracle Concepts - pfile and spfile http://www.dba-oracle.com/concepts/pfile_spfile.htm
5 of 5 21-07-2011 15:04