Oracle參數修改淺析
SCOPE = SPFILE
The change is applied in the server parameter file only. The effect is as follows:
For dynamic parameters, the change is effective at the next startup and is persistent.
For static parameters, the behavior. is the same as for dynamic parameters. This is the only SCOPE specification allowed for static parameters.
SCOPE = MEMORY
The change is applied in memory only. The effect is as follows:
For dynamic parameters, the effect is immediate, but it is not persistent because the server parameter file is not updated.
For static parameters, this specification is not allowed.
SCOPE = BOTH
The change is applied in both the server parameter file and memory. The effect is as follows:
For dynamic parameters, the effect is immediate and persistent.
For static parameters, this specification is not allowed.
反過來推理下:
|
啟動和修改方式 |
動態參數 |
靜態參數 |
|
SPFILE
啟動 |
Scope=spfile |
更新spfile |
更新spfile |
|
重啟後永久生效 |
重啟後永久生效 |
|
Scope=memory |
更新記憶體 |
不允許 |
|
立即生效,重啟後無效 |
|
Scope=both(預設) |
更新記憶體和spfile |
不允許 |
|
立即並永久生效 |
|
PFILE
啟動 |
Scope=spfile |
不允許 |
不允許 |
|
Scope=memory(預設) |
更新記憶體 |
不允許 |
|
立即生效,重啟後無效 |
|
Scope=both |
不允許 |
不允許 |
從以上可以看出,由於pfile只能手工修改,所以以pfile啟動後,僅動態參數可以立即修改生效,但執行個體重啟後無效;以spfile啟動,靜態參數可以修改重啟後生效,動態參數可以以三種方式修改生效。
如何查看一個參數是動態還是靜態,可以通過v$parameter視圖中的issys_modifiable獲得:
此欄位含義:
?IMMEDIATE - Parameter can be changed with ALTER SYSTEM regardless of the type of parameter file used to start the instance. The change takes effect immediately.
?DEFERRED - Parameter can be changed with ALTER SYSTEM regardless of the type of parameter file used to start the instance. The change takes effect in subsequent sessions.
?FALSE - Parameter cannot be changed with ALTER SYSTEM unless a server parameter file was used to start the instance. The change takes effect in subsequent instances
從解釋來看,immediate和deferred都屬於動態參數,但deferred比較特殊,對當前已經串連會話不生效。False屬於靜態參數,只能重啟後生效。
SQL> select issys_modifiable,count(*) from v$parameter group by issys_modifiable;
ISSYS_MOD COUNT(*)
--------- ----------
IMMEDIATE 145
FALSE 107
DEFERRED 7