oracle 11g对于初始化增加了一个特别有用的功能,它可以根据内存中的参数设置来创建初始化参数文件。
oracle从9i推出spfile之后,就给出了使用pfile创建spfile以及由spfile创建pfile的语法。
在oracle 11g中,oracle增强了这种语法,使得创建pfile或spfile时,不在需要指定一个物理的文件,而是可以从当前内存中的设置来获取参数配置。
采用这种方式创建的pfile或spfile,可以保证获得的参数就是当前运行的参数,而如果从pfile或spfile则无法确保文件中的参数设置与数据库运行的参数设置一致。
语法很简单,将创建时的from语句后面的文件类型pfile或spfile改为memory就可以了。
代码片段:
[oracle@yangtk ~]$ sqlplus "/ as sysdba"
sql*plus: release 11.1.0.6.0 - production on thu jan 10 15:06:30 2008
copyright (c) 1982, 2007, oracle. all rights reserved.
connected to:
oracle database 11g enterprise edition release 11.1.0.6.0 - production
with the partitioning, olap, data mining and real application testing options
sql> create pfile='/home/oracle/initora11g_p.ora' from memory;
file created.
sql> create spfile='/home/oracle/spfileora11g_p.ora' from memory;
file created.
|
注意:上面的这种方式要求数据库至少处于nomount状态,否则会出现报错:
sql> shutdown immediate
database closed.
database dismounted.
oracle instance shut down.
sql> create pfile='/home/oracle/initora11g_p.ora' from memory;
create pfile='/home/oracle/initora11g_p.ora' from memory
*
error at line 1:
ora-00922: missing or invalid option
sql> create spfile='/home/oracle/spfileora11g_p.ora' from memory;
create spfile='/home/oracle/spfileora11g_p.ora' from memory
*
error at line 1:
ora-00922: missing or invalid option
sql> startup nomount
oracle instance started.
total system global area 267825152 bytes
fixed size 1299316 bytes
variable size 176163980 bytes
database buffers 88080384 bytes
redo buffers 2281472 bytes
sql> create pfile='/home/oracle/initora11g_p.ora' from memory;
file created.
sql> create spfile='/home/oracle/spfileora11g_p.ora' from memory;
file created.
|