Oracle PFILE and SPFILE: Initialization
Parameter Files
Oracle databases use initialization parameter files to define settings (memory sizes, file locations, etc.)
when an instance starts. These parameters can be stored in a PFILE (Parameter File, a plain-text file
usually named init<SID>.ora ) or an SPFILE (Server Parameter File, a binary file, usually named
spfile<SID>.ora ). The SPFILE (introduced in Oracle 9i) is server-managed and allows dynamic
changes via ALTER SYSTEM , while the PFILE is manually edited and requires a restart to apply changes
12. By default, if an SPFILE exists, Oracle uses it at startup; otherwise it looks for a PFILE
(e.g. init<SID>.ora ) 1 3.
What is a PFILE? (Text Init File)
• Definition: A PFILE (also called init.ora ) is a static text file containing name=value pairs of
database initialization parameters. It can be opened with any ASCII text editor (such as vi on
Unix or Notepad on Windows) 4 2 . For example:
DB_NAME='ORCL'
MEMORY_TARGET=1G
PROCESSES=150
• Purpose: The PFILE is used at instance startup to set initial configuration (e.g. memory
allocation, file paths). You edit parameters in the PFILE directly, then restart the database for
changes to take effect 2 5. In practice, Oracle often installs a sample PFILE
( initsmpl.ora ) under ORACLE_HOME/admin/<SID>/pfile or ORACLE_HOME/dbs that you
can copy and modify 6 7 .
• Use cases: PFILEs are useful for initial database creation, recovery scenarios, or remote startups.
For example, an administrator might keep a local PFILE copy to start a remote database:
SQL> CONNECT sys/password AS SYSDBA
SQL> STARTUP PFILE='/path/to/init.ora';
• Location: By default Oracle searches the PFILE in $ORACLE_HOME/dbs (Unix/Linux) or
%ORACLE_HOME%\database (Windows) 8 9 . The default name is init<SID>.ora . You can
override this by specifying PFILE='/full/path/init.ora' in the STARTUP command
9 10 .
• Note: Changes in a PFILE do not persist automatically. If you change a static parameter in a
running database, you must both issue an ALTER SYSTEM (if dynamic) or edit the PFILE and
restart the instance 11 5 . RMAN does not back up PFILEs by default, so you should manually
archive any PFILE you rely on 12 .
1
What is an SPFILE? (Server Parameter File)
• Definition: An SPFILE is a binary, server-side file that stores the same init parameters as a PFILE.
Unlike a text PFILE, the SPFILE cannot be edited with a text editor. Instead, it is managed by the
database itself 13 14 . Oracle introduced SPFILE in 9i to allow persistent, dynamic configuration. •
Purpose: The SPFILE allows you to change database parameters at runtime using ALTER
SYSTEM ... SCOPE=SPFILE (or SCOPE=BOTH ) and have those changes survive shutdown and
restart 15 11 . In other words, parameters altered in the SPFILE become persistent. This makes
SPFILEs ideal for production systems because you avoid manual edits and ensure consistency.
• Behavior: If a database is started with an SPFILE, most ALTER SYSTEM changes (for dynamic
parameters) are written directly to the SPFILE without requiring a manual edit or restart 15 11 .
For example, you can immediately issue
ALTER SYSTEM SET SESSIONS=200 SCOPE=SPFILE;
and after a restart, the new SESSIONS value will be in effect 16 11 . (Static parameters still require a
restart to apply, even when set in the SPFILE.)
• Storage: By default Oracle places the SPFILE in $ORACLE_HOME/dbs (Unix) or %ORACLE_HOME%
\database (Windows) as spfile<SID>.ora 9 17 . However, you can locate it anywhere if you
reference it in a PFILE or via the STARTUP command 18 19 . In RAC or ASM environments it is
common to store the SPFILE on shared storage (e.g. an ASM diskgroup) so all instances can
access it 20 21 .
• Note: Since the SPFILE is binary, it has a header/footer and cannot be hand-edited. All changes
must go through SQL (e.g. ALTER SYSTEM ). Oracle automatically validates any change,
reducing errors 22 23 . Also, RMAN will include the SPFILE in its backups 24 .
Key Differences Between PFILE and SPFILE
• Format: PFILE is plain-text ( init.ora ), SPFILE is binary. You can open and read a PFILE with a
text editor, but you cannot directly edit an SPFILE 2 13 .
• Editability: PFILE parameters are changed by editing the file and restarting the database. SPFILE
parameters must be changed with ALTER SYSTEM commands (optionally with SCOPE=SPFILE or
BOTH ) 13 11 .
• Persistence: PFILE edits only affect the next instance startup if saved in the file. SPFILE changes
persist across shutdowns, because the SPFILE is re-used at each startup 11 15 . In other words,
PFILE changes are not automatically persistent, but SPFILE changes are.
• Default use: If an SPFILE exists, Oracle uses it by default on STARTUP ; if not, it looks for a PFILE
3 25
. You must explicitly specify PFILE= to force using a text file.
• Server vs Client: The SPFILE is server-side (stored on the database host) and centrally managed.
A PFILE is also usually on the server, but a DBA can copy it to a client machine for remote startup.
(For example, Oracle Base notes a DBA may keep PFILE copies on a local PC for remote operations
26 .)
• Backup behavior: Oracle does not backup PFILEs automatically with RMAN; administrators
should archive copies of PFILEs. In contrast, RMAN does include the SPFILE in backups 12 24 .
• RAC considerations: In RAC, all instances use the same SPFILE at startup 27 21 . A PFILE used in
RAC is typically identical or contains an SPFILE= pointer line (see below) 28 21 .
2
Creating, Editing, and Using a PFILE
1. Create from sample or existing SPFILE: You can start with Oracle’s sample file (e.g.
initsmpl.ora under ORACLE_HOME/admin/<SID>/pfile or .../dbs ) and edit it to set
parameters 29 . Alternatively, if the database is running with an SPFILE, you can export its
parameters to a PFILE via:
SQL> CREATE PFILE='/path/my_init.ora' FROM SPFILE;
This generates a text file ( my_init.ora ) containing all current parameter values 30 31 .
2. Edit parameters: Open the PFILE in a text editor. Modify or add parameter_name=value lines
as needed. (Oracle requires an ASCII editor; e.g. use vi or Notepad 4 .) For multi-value
parameters (like CONTROL_FILES ), use the parameter=(value1,value2,...) format 32 .
Save changes.
3. Start the instance with the PFILE: If you specify no PFILE, Oracle searches defaults (see above).
To use your file, start the database with:
SQL> STARTUP PFILE='/path/my_init.ora';
This tells Oracle to read the initialization parameters from your text file. (If you wanted to use a
specific SPFILE, you could instead use a single-line PFILE containing just SPFILE='/path/to/
spfile.ora' 19 .)
4. Apply new settings: Any changed or new parameters in the PFILE take effect at startup. Static
parameters (those not dynamically changeable) always require an instance restart regardless.
Dynamic parameters could be changed later by ALTER SYSTEM , but those edits would be in
memory (and lost without saving to file) unless you issue ALTER SYSTEM ... SCOPE=BOTH or
save to SPFILE 11 .
5. Use cases: PFILEs are commonly used for initial database setup, on Oracle versions prior to 9i,
or in emergencies when the SPFILE is corrupted. They are also handy for remote or scripted
startups where you want a known parameter file.
Converting Between PFILE and SPFILE
• Creating an SPFILE from a PFILE: To migrate or switch to a server parameter file, use the
CREATE SPFILE command. For example:
SQL> CREATE SPFILE FROM PFILE='/u01/app/oracle/dbs/init.ora';
This creates the default spfile<SID>.ora in $ORACLE_HOME/dbs (Unix) or
%ORACLE_HOME%\database (Windows) 33 34 . You can also specify an explicit SPFILE name:
SQL> CREATE SPFILE='/u01/app/oracle/dbs/myspfile.ora'
FROM PFILE='/u01/app/oracle/dbs/init.ora';
3
If you omit the SPFILE location, Oracle uses the default name and path. (If an SPFILE already
exists, it will be overwritten by this command.) 35 33 .
4
•
Creating a PFILE from an SPFILE: You can generate a text PFILE from the current SPFILE
settings. For example:
SQL> CREATE PFILE='/tmp/backup_init.ora' FROM SPFILE;
This writes all parameter values (including comments) into backup_init.ora 30 36 . You could
then edit this file if needed or keep it as a backup of the SPFILE parameters.
• Using a custom SPFILE at startup: If you want to start the database with an SPFILE in a
nondefault location, you can create a small PFILE that points to it. For example, a one-line PFILE
containing:
SPFILE='/shareddisk/mydb/spfilemydb.ora'
Then start with STARTUP PFILE='pointerfile.ora' 19 . Oracle will read that PFILE, see the
SPFILE line, and load the specified server parameter file. (This technique is often used in RAC
to point each node to a single shared SPFILE 28 .)
• After conversion: Once an SPFILE is created from a PFILE, use SHOW PARAMETER SPFILE in
SQL*Plus to verify its location and usage. Remember that changes to parameters in an SPFILE
must be done with ALTER SYSTEM (see below).
Modifying SPFILE Parameters with ALTER SYSTEM
When the instance is running from an SPFILE, you change parameters using SQL commands:
• Dynamic changes: For parameters that are dynamic (see
V$PARAMETER.ISSYS_MODIFIABLE = IMMEDIATE ), use ALTER SYSTEM SET name=value
SCOPE=BOTH; . This applies the change immediately in memory and writes it to the SPFILE so it
persists on restart. (If you omit SCOPE , BOTH is the default when using an SPFILE 37 .)
• Persistent-only changes: You can also use SCOPE=SPFILE to change the SPFILE value without
affecting the running instance. The new value will only take effect on the next startup. Example:
ALTER SYSTEM SET OPEN_CURSORS=300 SCOPE=SPFILE;
This records the change in the SPFILE; the current session’s OPEN_CURSORS stays the same until
a bounce, but future startups will use 300 16 38 .
• Checking parameters: Before altering, you can SHOW PARAMETER name; to see the current
values. After ALTER SYSTEM , repeat SHOW PARAMETER or query V$PARAMETER to confirm the
change (if SCOPE was BOTH, the new value shows immediately) 37 .
• SID-specific (RAC only): In Oracle RAC, you can set parameters for a specific instance by
adding SID='instancename' to the ALTER SYSTEM command. For example:
ALTER SYSTEM SET LARGE_POOL_SIZE=1G SID='node1' SCOPE=SPFILE;
This affects only the instance named NODE1. Such node-specific settings can be stored in the
SPFILE 39 40 .
5
•
Exporting to text: If you ever need a text copy of current SPFILE values, use CREATE PFILE
FROM SPFILE; as shown above. Likewise, to make major edits, you can CREATE PFILE , edit
it, then CREATE SPFILE FROM PFILE again.
PFILE/SPFILE in Oracle RAC
In a Real Application Clusters (RAC) setup, parameter files have special considerations:
• Shared SPFILE: All instances in a RAC database must use the same SPFILE 27 . This means the
SPFILE should be placed on shared storage (ASM disk group, shared filesystem, or NFS) so every
node can access it 20 40 . Oracle’s RAC installer/DBCA typically sets this up (e.g. placing
spfile<SID>.ora in an ASM diskgroup) 20 . Placing the SPFILE on local disk of one node is
not recommended, as other nodes wouldn’t see it 41 .
• PFILEs in RAC: If using PFILEs, each instance can have its own local PFILE, but those are typically
identical (or contain an SPFILE= pointer to the central SPFILE). Oracle recommends creating the
SPFILE first (e.g. from one PFILE) and then having each node start from it 28 . For example, a
node’s init<SID>.ora might simply contain:
SPFILE='+DATA/mydb/spfilemydb.ora'
to refer to the shared SPFILE 28 .
• Parameters in RAC: Since all instances share one SPFILE, global parameters apply to all nodes.
For instance, DB_CACHE_SIZE in the SPFILE affects every instance’s buffer cache. If you need an
instance-specific setting (like number of processes per node), use the SID= qualifier in
ALTER SYSTEM as shown above 39 .
• Creating from RAC config: In a RAC environment, using CREATE PFILE FROM SPFILE will
output all instances’ parameters. If you started one instance, it still reads from the single shared
SPFILE, so the resulting PFILE covers the cluster’s settings 42 .
• Search order: Oracle’s RAC parameter file search order includes Grid Plug-N-Play profiles first,
then the shared SPFILE (with sid and default names), and finally any PFILEs 43 . You usually don’t
need to alter this, but it explains how Oracle finds the right file in RAC.
Default and Custom File Locations
• Default names: By convention, Oracle looks for spfile<SID>.ora or spfile.ora (or
init<SID>.ora ) in the default directory. For example, on Unix/Linux it searches
$ORACLE_HOME/dbs/spfile<SID>.ora , then $ORACLE_HOME/dbs/spfile.ora , then
$ORACLE_HOME/dbs/init<SID>.ora 44 . On Windows, the default directory is typically
%ORACLE_HOME%\database 8 44 .
• Custom paths: You can place the PFILE or SPFILE anywhere by specifying its full path. When
creating an SPFILE from a PFILE, if the PFILE isn’t in the default location, include its full pathname
(similarly for CREATE PFILE FROM SPFILE ) 10 45 . When starting up, use the PFILE=
clause with the full path. Alternatively, define the parameter SPFILE='/my/path/
spfile.ora' inside a PFILE or use the STARTUP command’s PFILE option as above.
• DBCA and Installer: The Oracle Universal Installer or DBCA usually creates a PFILE or SPFILE in
the default location during database creation 13 . For a starter database, it might create
init.ora and then rename it once the SPFILE is in place 13 . After DBCA, the SPFILE is named
6
•
spfile<SID>.ora in the default directory 13 , and the original PFILE (if any) is not used unless
explicitly invoked.
Alternative storage: As noted, SPFILEs are often stored in ASM for RAC 20 21 . If you move an
SPFILE to a new ASM diskgroup, use ALTER SYSTEM SET SPFILE='/new/location/
spfile.ora' SCOPE=SPFILE or recreate it. In any case, specify the correct path in startup or
via a PFILE.
Example PFILE (init.ora) Content
Below is a simplified example of a PFILE (named init.ora ) drawn from Oracle’s documentation 46
47 . Each parameter is annotated with its purpose:
db_name='ORCL' # The local database name (DB_NAME). Combined
with DB_DOMAIN to form the global DB name.
memory_target=1G # Total memory target (SGA + PGA) for automatic
memory management.
processes=150 # Maximum number of OS processes (incl. user and
background processes).
audit_file_dest='/u01/app/oracle/admin/orcl/adump' # Location for audit trail
files.
audit_trail='DB' # Enables auditing to the database audit trail
('DB'). db_block_size=8192 # Database block size in bytes
(must match control file metadata).
db_domain='' # Optional DB domain name; empty means no domain.
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' # Flash
Recovery Area location. db_recovery_file_dest_size=2G # Size limit for
recovery area (e.g. flashback logs, archives).
diagnostic_dest='/u01/app/oracle' # Base directory for ADR (trace files,
alerts). dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)' # Configure
shared server: protocol and listener service name.
open_cursors=300 # Maximum open cursors (SQL statements) per
session. remote_login_passwordfile='EXCLUSIVE' # Password file mode for
SYS: EXCLUSIVE or SHARED.
undo_tablespace='UNDOTBS1' # Name of the undo (rollback) tablespace to use.
control_files=(ora_control1, ora_control2) # Names (or paths) of control
files for redundancy.
compatible='11.1.0' # Compatibility mode; ensures features are
compatible with older versions.
Each line sets a database initialization parameter ( name=value format). Parameters not shown (like
log_buffer , db_name , etc.) would similarly appear as parameter=value lines. Comment lines
(starting with # or -- ) can be added or values preceded by # to disable them 48 . In practice, you would
edit these values to match your system’s paths and sizing requirements, then start the database with
this PFILE.
7
Best Practices and Tips
• Use SPFILE when possible: Oracle recommends using a single SPFILE for managing parameters
(especially in RAC) 21 . It provides a centralized, persistent store of settings. Place the SPFILE on
shared storage (often in an ASM diskgroup) so all instances can access it 20 21 .
• Backup your files: Ensure you have backups of your PFILEs. Since RMAN does not save PFILEs
automatically 12 , keep copies in your backup procedures. The SPFILE, however, is backed up by
RMAN 24 .
• Version control: Consider keeping parameter files (PFILE or exported SPFILE contents) in
version control or change-control systems. This makes it easy to track changes over time or
recover from mistakes.
• Comment liberally: Add comments in your init files to explain non-default parameters. Oracle’s
sample initsmpl.ora uses # for alternative values and notes 48 ; you can do the same to
document why a parameter is set a certain way.
• Stay consistent in naming: Name your files clearly (e.g. initORCL.ora , spfileORCL.ora )
and store them in their canonical directories ( $ORACLE_HOME/dbs or $ORACLE_HOME/
database ). This ensures Oracle finds the right file by default.
• Test changes: For critical parameters, it’s wise to test changes on a non-production instance
first. Remember that not all parameters are dynamic; some require a shutdown and startup to
apply. For example, increasing db_block_size is not dynamic and would need a new database;
adjusting processes is a dynamic change (but will need a restart to use the SPFILE value).
• Node-specific settings in RAC: If using RAC, use the SID= clause in ALTER SYSTEM to set
parameters per node as needed 39 (e.g. EXTENT MANAGEMENT LOCAL on one node). This avoids
using separate PFILEs for each node.
• Monitor and document: After startup, verify the active parameters with SHOW PARAMETER or
queries on V$PARAMETER and V$SPPARAMETER . Keep a record of any manual edits to a PFILE or
persistent changes to an SPFILE.