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

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

2013-05-14 09:46 423 查看
查询初始化参数的方法很多,比如SHOW PARAMETER,或查询V$PARAMETER等,这里简单总结一下。
这一篇描述GV$SPPARAMETER参数的必要性。

前一篇文章介绍了V$SPPARAMETER参数,也说明了V$SPPARAMETER视图中的信息与GV$PARAMETER视图中的区别。
其实这里还有一个问题,就是GV$SPPARAMETER是否有意义。因为V$SPPARAMETER参数本身就包含了SID列,SPFILE中本身就包含了所有实例的设置,那么查询GV$SPPARAMETER视图是否就意义不大呢,其实不然。
因为RAC的各个节点可以使用统一的SPFILE启动,同样也可以选择不同的SPFILE来进行启动,这时GV$SPPARAMETER视图中获取结果,才是真正各个实例SPFILE中设置的结果。
这样说比较难以理解,看一个简单的例子:
SQL> select inst_id, name, value

2 from gv$system_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

SQL> select inst_id, sid, name, value

2 from gv$spparameter

3 where name = 'open_cursors';

INST_ID SID NAME VALUE

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

1 * open_cursors 300

1 test1 open_cursors 500

1 test2 open_cursors 700

2 * open_cursors 300

2 test1 open_cursors 500

2 test2 open_cursors 700

已选择6行。

SQL> select inst_id, name, value

2 from gv$system_parameter

3 where name = 'spfile';

INST_ID NAME VALUE

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

1 spfile +DATA/test/spfiletest.ora

2 spfile +DATA/test/spfiletest.ora

下面里面内存中参数来创建SPFILE,并利用新建的SPFILE来启动当前实例:
SQL> create spfile='/export/home/oracle/spfiletest1.ora' from memory;

文件已创建。

SQL> host

$ vi /export/home/oracle/inittest1.ora

"/export/home/oracle/inittest1.ora" [New file]

spfile=/export/home/oracle/spfiletest1.ora

"/export/home/oracle/inittest1.ora" [New file] 2 lines, 44 characters

$ exit

SQL> shutdown immediate

数据库已经关闭。

已经卸载数据库。

ORACLE例程已经关闭。

SQL> startup pfile=/export/home/oracle/inittest1.ora

ORACLE例程已经启动。

Total System Global Area 776896512 bytes

Fixed Size 2098776 bytes

Variable Size 246069672 bytes

Database Buffers 524288000 bytes

Redo Buffers 4440064 bytes

数据库装载完毕。

数据库已经打开。

下面检查spfile中的设置:
SQL> select inst_id, name, value

2 from gv$system_parameter

3 where name = 'spfile';

INST_ID NAME VALUE

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

1 spfile /export/home/oracle/spfiletest1.ora

2 spfile +DATA/test/spfiletest.ora

SQL> select inst_id, name, value

2 from gv$system_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

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

test1 open_cursors 600

test2 open_cursors 400

SQL> select inst_id, sid, name, value

2 from gv$spparameter

3 where name = 'open_cursors';

INST_ID SID NAME VALUE

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

2 * open_cursors 300

2 test1 open_cursors 500

2 test2 open_cursors 700

1 test1 open_cursors 600

1 test2 open_cursors 400

可以看到,由于两个实例采用了不同的SPFILE,导致两个实例上设置的对方实例的初始化参数值,与对方实例上当前设置值不符。
在上面的例子中,两个实例上真正的参数设置查询方式为:
SQL> select inst_id, sid, name, value

2 from gv$spparameter

3 where name = 'open_cursors'

4 and substr(sid, -1) = to_char(inst_id);

INST_ID SID NAME VALUE

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

2 test2 open_cursors 700

1 test1 open_cursors 600

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