Skip to Main Content

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, thomas.

Asked: June 25, 2001 - 9:45 am UTC

Last updated: September 14, 2009 - 10:06 am UTC

Version: 9.0.1

Viewed 1000+ times

You Asked

Tom,

I've just installed Oracle9i. I changed my init.ora settings but they don't seem to be changing. For example, I set the db_cache_size and shared_pool to a new value and restarted but my SGA size didn't change at all.

What's going on?

and Tom said...

The answer is a new feature, the Stored Parameter File (SPFILE).

In Oracle8i and before, when you started the database, the init.ora file for that database had to be on your client machine. If you attempted to remotely start a database instance, you needed to have a local copy of the init.ora as the Oracle backend process running on your client would process the init.ora.

In Oracle9i, the parameter file is stored in a binary format on the server itself -- you no longer need to have a local copy (although you may if you like) to start the database remotely. It also means that changes made via the ALTER SYSTEM command may now persist across server restarts. No more updating the init.ora.

The SPFILE is stored on the server in the location specified by the initialization parameter "spfile":

sys@TKYTE901.US.ORACLE.COM> show parameter spfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string %ORACLE_HOME%\DATABASE\SPFILE%
ORACLE_SID%.ORA
sys@TKYTE901.US.ORACLE.COM>

You can (but shouldn't unless you have some compelling reason to) change this location from the default.

This spfile is created via the new command "CREATE SPFILE" which has the syntax:

CREATE SPFILE = 'filename' FROM PFILE ='pfilename';


You can create a textual version of this binary parameter file using the CREATE PFILE command:

CREATE PFILE = 'pfilename' FROM SPFILE = 'filename';

This will always create the text parameter file on the SERVR (not on the client that executed this command). This might be used to export all parameters, make many changes to them, and then create a new SPFILE using this pfile.


In the event you want to use a PFILE (parameter file), you would use the PFILE= option on the startup command:


SQL> startup pfile=filename


When you make changes to system parameters now, you have an extended syntax on the ALTER SYSTEM command to set parameters:

ALTER SYSTEM set parameter = value SCOPE = MEMORY | SPFILE | BOTH;


The Scope clause allows to to set a system parameter:

o in memory -- affects the database right now, will not be in place after a restart

o in the spfile -- does not change the current setting of the parameter but will modify the spfile so that upon a restart this parameter will take effect

o both -- changes the current instances setting as well as updates the spfile.







Rating

  (17 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Joel, June 26, 2001 - 1:02 pm UTC


init.ora in 9i database

Umesh S. Kasturi, June 27, 2001 - 7:46 am UTC

a good concept..but I will be happy to get more details..


Nikhil Saxena, October 31, 2001 - 6:52 am UTC

I was not knowing this before

Oracle9i, init.ora isn't working

Hamilton Budayao, March 12, 2003 - 5:16 am UTC

thanks for the information. this site is really helpful.

i had the same problem, i can't change my audit_trail parameter to true in 9i but can easily change it in 8.1.7. version using init.ora file.

however, i've tried changing the parameter using the alter system command,
ALTER SYSTEM SET AUDIT_TRAIL = DB SCOPE = BOTH
what did i miss if i have encountered the error "specified initialization parameter cannot be modified"? can you please answer my question or just give a detailed procedure on how to change a parameter value in 9i enviromentment


Tom Kyte
March 12, 2003 - 7:59 am UTC

use scope = spfile

and then restart. that error says "sorry, that is one you cannot change online, hence scope=both won't work"

A reader, May 08, 2003 - 6:15 pm UTC

Sorry, I am still having problems:

SQL> create spfile='D:\oracle9i\admin\SHAN\pfile\SPFILESHAN.ORA' from
  2  pfile='D:\oracle9i\admin\SHAN\scripts\init.ora';

File created.

SQL> sho parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string

SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
Database opened.
SQL> sho parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string

Why is the spfile still blank after a restart? Do we have to mention the full spfile name everytime we startup like this:

SQL> startup pfile='D:\oracle9i\admin\SHAN\pfile\SPFILESHAN.ORA'
SP2-0714: invalid combination of STARTUP options

SQL> startup pfile='D:\oracle9i\admin\SHAN\pfile\SPFILESHAN.ORA'
LRM-00123: invalid character 0 found in the input file
ORA-01078: failure in processing system parameters

Please clarify with an example. Thank you verymuch.
Regards,

Shan. 

Tom Kyte
May 09, 2003 - 1:05 pm UTC

unless you set it -- it'll look for it in the default location.

just go:

create spfile from pfile=.....

and it'll put it in the dbs directory named correctly for the default.


you obviously cannot use an spfile as a pfile -- spfiles are binary, pfiles are ascii text.

A reader, May 09, 2003 - 2:03 pm UTC

Got it! Thank you.

One more question, if we create the spfile at a non-default location, how do we specify that during the startup?

Tom Kyte
May 09, 2003 - 3:14 pm UTC

you can use a pfile with spfile= for example -- but i see no possible logical reasonable reason to not use the default location.

Why binary format...

Kamal Kishore, May 09, 2003 - 7:15 pm UTC

Hi Tom,
I always wondered the reasoning behind making the SPFILE a binary file and not a regular text file (like the init.ora file was).
Was there a reason (security ...), to make the format binary?
Also, If you change a parameter in your SPFILE using ALTER SYSTEM command and later restart the database, only to find that something went wrong and database will not start. In this situation, how to revert back the changed setting (can not edit the file, since it is in binary format).
Thanks a lot for the explanation on this concept.


Tom Kyte
May 09, 2003 - 7:35 pm UTC

it is a system maintained file, not be to messed about with by anyone via any mechanism other then SQL commands.

Making it a text file would be too tempting for us -- we would be tempted just to edit the thing. Hence, binary -- like a control file, datafile redo log file, dmp file....

you can easily recover from a mistake like that.
</code> http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:2200190221847#6742226475226 <code>


Very useful.

Sreeviswa Peesapati, May 31, 2003 - 10:31 am UTC

I am very much impressed by the way Tom answers the doubts. Thank you Tom, it is Very helpful.

-Viswa

A reader, July 30, 2003 - 11:24 am UTC


insufficient priviledge

jack, November 11, 2003 - 1:09 am UTC

I've tried to execute "create pfile='D:\oracle9i\admin\SHAN\pfile\SPFILESHAN.ORA' from pfile='D:\oracle9i\admin\SHAN\scripts\init.ora'" in sql plus, but it returns "insufficient privileges".
my login is system/manager. What privilege do I need? system is supposed to be a dba?



Tom Kyte
November 11, 2003 - 7:13 am UTC

you need to be as SYSDBA

just being a 'dba' isn't good enough.

Oracle9i not using Spfile??

Rahul, June 09, 2004 - 9:19 am UTC

Hi Tom

I am using oracle9.0.1.1.1 on windows XP professional with p4. I have database started with spfile by default and I made some changes in memory related parameters then i just restarted the machine. Oracle got up automatically but it is not using spfile, because when i tried below command it gave me error..

SQL> alter system set sort_area_size=524288 scope=spfile;
alter system set sort_area_size=524288 scope=spfile
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE specified at startup

I checked that my spfile is lying in the default location in DATABASE directory. Then how is it possible that oracle started up with using pfile?
one more question how can one know that oracle is running with which file spfile or pfile ? is there any sql to check this?

Regards
Rahul.
 

Tom Kyte
June 09, 2004 - 9:58 am UTC

on windows it uses "services" and other things to startup. the registry controls things
</code> http://docs.oracle.com/docs/cd/B10501_01/win.920/a95491/admin.htm#1008758 <code>

you can remove the ora_%ORACLE_SID%_pfile entry and it'll use the spfile (else the startup command given by oradim will contain pfile=filename....)

It's Done.

Rahul, June 10, 2004 - 12:08 am UTC

Yes Tom you were right. When I restarted the machine, db got up using services and used pfile but when manually i shut it down and started it up then it took spfile itself.

Thanks.

How can i find the correct PFILE ?

Sujit, December 24, 2004 - 5:42 am UTC

Hi,
I cannot startup oracle after power failure.
when i try startup
ora - 01078 and
lrm - 00109 : could not open parameter file '/opt/oracle/product/9.2.0/dbs/inittest_crm.ora'
occures.
at the dbs directory there is not a file named as inittest_crm.ora..
There are pfiles and spfiles but I dont know which is used for startup..
How can i find the correct PFILE i was using? The persons starting up the database is no longer in contact with me.

Tom Kyte
December 24, 2004 - 9:19 am UTC

you'll need to find one. it could have been on that persons laptop, it could have been on the OMS server machine (if you are using enterprise manager). it could be anywhere in your network.


you can rebuild one from your alert logs -- before each startup, it'll have printed out the settings you used last.

Re: How can i find the correct PFILE ?

Sujit, December 27, 2004 - 5:55 am UTC

Thanx Tom, It was very useful to me.

Location of a PFILE

Aníbal Gattás, September 07, 2009 - 12:57 pm UTC

Tom, Is there any view or table that register the location from a pfile if you start up the database with it? I understand the pfile could be anywhere, not only on the server, but is there a way to identify where is the file located? (don't know, may be if it's located on the server Oracle keep the path somewhere). Thanks in advance for your response.

Location of a PFILE

Aníbal Gattás, September 08, 2009 - 11:45 am UTC

Tom, thanks for your answer. Show parameter spfile doesn't show a path if the database has been started with a pfile (or at least not with one linked to a spfile). Is there any other command or place (table, view, etc.) to look for the path of a PFile if you started the database with one of those? A colleague told me he support a client's database that, from time to time is started with differents pfiles (don't know the reason) and sometimes he needs to identify which pfile they used to start the database, but he's unable to do so without asking the client's DBAs (and sometimes even though cause the guys don't remember). Thanks for your help.
Tom Kyte
September 08, 2009 - 9:39 pm UTC

... Show parameter spfile doesn't show a path if the
database has been started with a pfile ...

yeah, well, you asked about the SPFILE.

the pfile - might not even be on the server, the pfile is on the client that started the database - it could be on any machine in your environment.


select name || '=' || value from v$parameter where isdefault = 'FALSE'

will produce your pfile contents for you.

Location of a PFILE

Aníbal Gattás, September 09, 2009 - 9:51 am UTC

Tom, thanks for your answer. If you read carefully you'll see I asked for a PFILE from the begining. Anyway, many thanks for the select statement to generate the file, can be useful to re create it and compare it with the other files. Cheers.
Tom Kyte
September 14, 2009 - 10:06 am UTC

this was a question about SPFILES. Sorry, I read the header and answered...