您的位置:首页 > 数据库 > Oracle

oracle技术之oracle查询初始化参数的方法(三)

2013-05-14 09:52 351 查看
查询初始化参数的方法很多,比如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视图获取的查询。

oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息