楊廷琨(yangtingkun)
云和恩墨 CTO
高級咨詢(xún)顧問(wèn),Oracle ACE 總監,ITPUB Oracle 數據庫管理版版主
參數文件是Oracle數據庫文件中級別最低,也是最基本的文件,但是也是數據庫實(shí)例啟動(dòng)第一個(gè)涉及的文件。如果參數文件缺失或者某些參數設置錯誤,數據庫就無(wú)法啟動(dòng)。
我們知道:使用 SHOW PARAMETER 查詢(xún),看到的是當前會(huì )話(huà)可以看到的初始化參數,那么這個(gè)參數導致是全局設置還是當前實(shí)例設置的,是從這個(gè)命令中看不到的。
雖然 Oracle 提供了 GV$ 開(kāi)頭的初始化參數,可以用來(lái)查詢(xún)兩個(gè)實(shí)例上的設置,但是情況并不是這么簡(jiǎn)單的。我們可以初步思考一下:從實(shí)例級別和會(huì )話(huà)級別,再加上多個(gè)實(shí)例,這是一個(gè)笛卡爾積的可能性,如果沒(méi)有清晰的思路,極有可能被輸出搞得迷惑不已。。
我們通過(guò)一個(gè)簡(jiǎn)單的例子來(lái)分析一下:
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 Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options 斷開(kāi)
SQL> set instance test2
Oracle Database 11g Release 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 Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options 斷開(kāi)
SQL> set instance local
Oracle Database 11g Release 11.1.0.0.0 - Production
SQL> conn / as sysdba
已連接。
現在來(lái)看看不同的查詢(xún)方法得到的結果:
SQL> select name, value
2 from v$parameter
3 where name = 'open_cursors';NAME VALUE
------------------------------ --------------------------------
open_cursors 500SQL> 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 400SQL> 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 400SQL> 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 沒(méi)有什么不同,其實(shí)不然,如果 alter system set 的時(shí)候只修改了 spfile 或只修改了 memory 參數,結果就會(huì )不同:
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 600SQL> 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 400SQL> 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
從上面的對比就可以看出,通過(guò) GV$ 視圖訪(fǎng)問(wèn)的結果和 SPFILE 中包含的信息其實(shí)是兩回事。
除了上面介紹的幾種視圖之外,CREATE PFILE 其實(shí)也是一個(gè)不錯的選擇,在10g 以前只能 CREATE PFILE FROM SPFILE,得到的結果類(lèi)似于對 VSPPARAMETER 視圖的查詢(xún),而11g增加了 CREATE PFILE FROM MEMORY 選項,這個(gè)得到的結果類(lèi)似于從 GV$SYSTEM_PARAMETER 視圖獲取的查詢(xún)。
聯(lián)系客服