您在这里:首页 > 学员专区 > 技术文章
Oracle视频
Oracle
CUUG课程

查询初始化参数的方法(三)

 

查询初始化参数的方法很多,比如SHOW PARAMETER,或查询V$PARAMETER等,这里简单总结一下。

这一篇介绍V$SPPARAMETER视图于GV$PARAMETER视图的不同。

 

上一篇介绍了V$SYSTEM_PARAMETER和V$PARAMETER视图之间的区别,这篇主要讨论RAC环境下初始化参数的查询。

前文已经提到,使用SHOW PARAMETER查询,看到的是当前会话可以看到的初始化参数,那么这个参数导致是全局设置还是当前实例设置的,是从这个命令中看不到的。

虽然Oracle提供了GV$开头的初始化参数,可以用来查询两个实例上的设置,但是情况并不是这么简单的。

一个简单的例子:

SQL> show parameter open_cursors

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

open_cursors                         integer     300

SQL> alter system set open_cursors = 500 scope = both sid = 'test1';

系统已更改。

SQL> disc

从Oracle Database11gEnterprise Edition Release11.1.0.6.0 - 64bit Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options断开

SQL> set instance test2

Oracle Database11gRelease 11.1.0.0.0 - Production

SQL> conn sys as sysdba

输入口令:

已连接。

SQL> alter system set open_cursors = 400 scope = both sid = 'test2';

系统已更改。

SQL> disc

从Oracle Database11gEnterprise Edition Release11.1.0.6.0 - 64bit Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options断开

SQL> set instance local

Oracle Database11gRelease11.1.0.0.0 - Production

SQL> conn / as sysdba

已连接。

现在来看看不同的查询方法得到的结果:

SQL> select name, value

  2  from v$parameter

  3  where name = 'open_cursors';

NAME                           VALUE

------------------------------ --------------------------------------------------

open_cursors                   500

SQL> select inst_id, name, value

  2  from gv$parameter

  3  where name = 'open_cursors';

   INST_ID NAME                           VALUE

---------- ------------------------------ --------------------------------------------------

         1 open_cursors                   500

         2 open_cursors                   400

SQL> show parameter open_cursors

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

open_cursors                         integer     500

SQL> select sid, name, value

  2  from v$spparameter

  3  where name = 'open_cursors';

SID        NAME                           VALUE

---------- ------------------------------ --------------------------------------------------

*          open_cursors                   300

test1      open_cursors                   500

test2      open_cursors                   400

SQL> show spparameter open_cursors

SID      NAME                          TYPE        VALUE

-------- ----------------------------- ----------- ----------------------------

*        open_cursors                  integer     300

test2    open_cursors                  integer     400

test1    open_cursors                  integer     500

似乎除了看不到全局设置外,GV$PARAMETER参数和V$SPPARAMETER没有什么不同,其实不然,如果alter system set的时候只修改了spfile或只修改了memory参数,结果就会不同:

SQL> alter system set open_cursors = 600 scope = memory sid = 'test1';

系统已更改。

SQL> alter system set open_cursors = 700 scope = spfile sid = 'test2';

系统已更改。

SQL> select name, value

  2  from v$parameter

  3  where name = 'open_cursors';

NAME                           VALUE

------------------------------ --------------------------------------------------

open_cursors                   600

SQL> select inst_id, name, value

  2  from gv$parameter

  3  where name = 'open_cursors';

   INST_ID NAME                           VALUE

---------- ------------------------------ --------------------------------------------------

         1 open_cursors                   600

         2 open_cursors                   400

SQL> select sid, name, value

  2  from v$spparameter

  3  where name = 'open_cursors';

SID        NAME                           VALUE

---------- ------------------------------ --------------------------------------------------

*          open_cursors                   300

test1      open_cursors                   500

test2      open_cursors                   700

从上面的对比就可以看出,通过GV$视图访问的结果和SPFILE中包含的信息其实是两回事。

除了上面介绍的几种视图之外,CREATE PFILE其实也是一个不错的选择,在10g以前只能CREATE PFILE FROM SPFILE,得到的结果类似于对VSPPARAMETER视图的查询,而11g增加了CREATE PFILE FROM MEMORY选项,这个得到的结果类似于从GV$SYSTEM_PARAMETER视图获取的查询。

 

 

(以上内容摘于网络,如有侵权,请告之,将第一时间删除)

相关文章 [上一篇] 查询初始化参数的方法(二)
010-88589926(88587026)
CUUG热门培训课程
Oracle DBA就业培训
CUUG名师
网络课程
技术沙龙
最新动态

总机:(010)-88589926,88589826,88587026 QQ讨论群:243729577 182441349 邮箱:cuug_bj@cuug.com
通信地址:北京市海淀区紫竹院路98号北京化工大学科技园609室(CUUG)邮政编码:100089 
中国UNIX用户协会 Copyright 2010  ALL Rights Reserved 北京神脑资讯技术有限公司
京ICP备11008061号  京公网安备110108006275号