就Oracle的spfile和pfile的区别主要是spfile的修改是可以在线的,而pfile的修改必须关闭数据库,到参数文件所在路径下通过vi或记事本等文本编辑工具修改。(因为参数文件里面的内容太多,编辑起来容易导致错误的编辑到其它的参数,从而导致数据库无法起来,所以在9i以前一般都是要备份pfile后再来做参数的修改,而且修改任何参数都需要停库,非常的不方便;在9i以后的spfile就可以同通过命令修改指定的参数了,而且有很多参数都不用重启数据库,能够在线生效,这个在线生效的参数会随着数据库的版本增高而增加。如果参数修改有问题数据库起不来了可以在nomount状态下创建成pfile再修改回来即可。)
修改spfile参数的三种模式:
scope=both 立即并永久改变,(默认模式)
scope=spfile 下次启动执行新的改变。
scope=memory 立即临时改变下次启动新参数失效
spfile 修改的方法:
SQL> alter system set processes = 100 scope=both; ----该参数不支持动态修改,必须修改完后重启数据库
alter system set processes = 100 scope=both
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
-------------------------------------------------------------------------------------------------------------------------------
SQL> show parameter pga;
NAME TYPE VALUE
------------------------------------ -------- ------
pga_aggregate_target big inte 798M
ger
SQL> alter system set pga_aggregate_target = 500m scope=both; -----该参数支持动态修改,所以就立即生效了
System altered.
SQL> show parameter pga;
NAME TYPE VALUE
------------------------------------ -------- ------
pga_aggregate_target big inte 500M
ger
SQL>
SQL> alter system set processes = 100 scope=spfile; ----修改完后重启数据库能生效,不信你试试。
System altered.
SQL> alter system set pga_aggregate_target = 700m scope=spfile; ----当然也可以选择数据库下次启动的时候生效。
System altered.
SQL> alter system set processes = 100 scope=memory; ----因为该参数不支持动态修改,同样也就无法实现立即生效,下次启动失效。
alter system set processes = 100 scope=memory
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
SQL>
SQL> alter system set pga_aggregate_target = 600m scope=memory; ---因为该参数支持动态修改,当然也就可以实现立即生效,下次启动失效咯。
System altered.
SQL>
如果使用的是pfile则无法通过命令进行修改,会报ORA-02095或32001错误。
SQL> alter system set processes = 100;
alter system set processes = 100
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
SQL> alter system set processes = 100 scope=spfile;
alter system set processes = 100 scope=spfile
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE specified at startup
SQL> alter system set processes = 100 scope=both;
alter system set processes = 100 scope=both
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
SQL> alter system set processes = 100 scope=memory;
alter system set processes = 100 scope=memory
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified
SQL>
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
