oracle 会话实例,返璞归真:Oracle实例级别和会话级别的参数设置辨析
楊廷琨(yangtingkun)
云和恩墨 CTO
高級(jí)咨詢顧問,Oracle ACE 總監(jiān),ITPUB Oracle 數(shù)據(jù)庫管理版版主
參數(shù)文件是Oracle數(shù)據(jù)庫文件中級(jí)別最低,也是最基本的文件,但是也是數(shù)據(jù)庫實(shí)例啟動(dòng)第一個(gè)涉及的文件。如果參數(shù)文件缺失或者某些參數(shù)設(shè)置錯(cuò)誤,數(shù)據(jù)庫就無法啟動(dòng)。Oracle實(shí)例級(jí)別和會(huì)話級(jí)別的參數(shù)有時(shí)候容易混淆,必須清晰的明確這兩者的差別,才能在種種變更中成竹在胸。我們來看看V$PARAMETER 和 V$SYSTEM_PARAMETER 視圖的區(qū)別。
一般在查詢初始化參數(shù)的時(shí)候都習(xí)慣性的使用 SHOW PARAMETER,也就是查詢 V$PARAMETER 視圖。但是有些時(shí)候查詢V$PARAMETER視圖得到的結(jié)果并不準(zhǔn)確。
我們通過query_rewrite_enabled這個(gè)參數(shù)來做一個(gè)驗(yàn)證。SQL> show parameter query_rewrite_enabled
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TYPE ? ? ? ?VALUE------------------------------------ ----------- --------------------query_rewrite_enabled ? ? ? ? ? ? ? ?string ? ? ?TRUESQL> select name, value?2 ?from v$parameter?3 ?where name = 'query_rewrite_enabled';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ----------------------------query_rewrite_enabled ? ? ? ? ? ? ? ? ? ?TRUE
SQL> select name, value?2 ?from v$system_parameter?3 ?where name = 'query_rewrite_enabled';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ----------------------------query_rewrite_enabled ? ? ? ? ? ? ? ? ? ?TRUE
這時(shí)候如果在會(huì)話級(jí)修改 query_rewrite_enabled 這個(gè)初始化參數(shù):SQL> alter session set query_rewrite_enabled = false;
會(huì)話已更改。
SQL> show parameter query_rewrite_enabled
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TYPE ? ? ? ?VALUE------------------------------------ ----------- -------------------query_rewrite_enabled ? ? ? ? ? ? ? ?string ? ? ?FALSESQL> select name, value?2 ?from v$parameter?3 ?where name = 'query_rewrite_enabled';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ---------------------------query_rewrite_enabled ? ? ? ? ? ? ? ? ? ?FALSE
SQL> select name, value?2 ?from v$system_parameter?3 ?where name = 'query_rewrite_enabled';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ---------------------------query_rewrite_enabled ? ? ? ? ? ? ? ? ? ?TRUE
可以看到,show parameter 和查詢 v$parameter 視圖的結(jié)果都是 FALSE,而剛才做的修改只是會(huì)話級(jí),并沒有修改系統(tǒng)的初始化參數(shù)。
我們應(yīng)該形成的知識(shí)常識(shí):V$PARAMETER 視圖反映的是初始化參數(shù)在當(dāng)前會(huì)話中生效的值,而 V$SYSTEM_PARAMETER 反映的才是實(shí)例級(jí)上的初始化參數(shù)。
再來看看延遲參數(shù)修改的情況:SQL> select name, value?2 ?from v$parameter?3 ?where name = 'recyclebin';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ------------------------------------recyclebin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? on
SQL> select name, value?2 ?from v$system_parameter?3 ?where name = 'recyclebin';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ------------------------------------recyclebin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? on
SQL> alter system set recyclebin = off deferred scope = memory;
系統(tǒng)已更改。
SQL> select name, value?2 ?from v$parameter?3 ?where name = 'recyclebin';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ------------------------------------recyclebin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? on
SQL> select name, value?2 ?from v$system_parameter?3 ?where name = 'recyclebin';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ------------------------------------recyclebin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OFF
結(jié)果和前面的恰好反過來,v$parameter 視圖中的結(jié)果沒有發(fā)生變化,而 v$system_parameter 視圖的結(jié)果變成了 OFF。
這是因?yàn)檠舆t修改對(duì)數(shù)據(jù)庫中當(dāng)前存在的會(huì)話不生效,因此反映當(dāng)前會(huì)話情況的 v$parameter 視圖結(jié)果不變,而對(duì)于系統(tǒng)而言,初始化參數(shù)已經(jīng)改變,而且所有新建會(huì)話的參數(shù)也會(huì)改變,所以 v$system_parameter 視圖的結(jié)果發(fā)生了改變。SQL> CONN YANGTK/YANGTK@YTK111已連接。SQL> select name, value?2 ?from v$parameter?3 ?where name = 'recyclebin';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ---------------------------recyclebin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OFF
SQL> select name, value?2 ?from v$system_parameter?3 ?where name = 'recyclebin';
NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? VALUE---------------------------------------- ---------------------------recyclebin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OFF
根據(jù)這兩個(gè)例子可以獲得的常識(shí)是:利用 V$PARAMETER 視圖獲取系統(tǒng)的啟動(dòng)初始化參數(shù)是不準(zhǔn)確的,應(yīng)該從 V$SYSTEM_PARAMETER 視圖來獲取。如何加入"云和恩墨大講堂"微信群
總結(jié)
以上是生活随笔為你收集整理的oracle 会话实例,返璞归真:Oracle实例级别和会话级别的参数设置辨析的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle走当前时间分区,Oracle
- 下一篇: win8oracle10g安装报错,Wi