Oracle引數修改小結

huangdazhu發表於2014-02-27

Oracle中有些引數是可以在session級別修改,有些則必須在system級別修改,有些引數不需要重啟就能馬上生效,有些引數必須重啟才能生效,那麼如何知道這些資訊呢?可以從v$parameter檢視中得出,重點關注這個檢視的以下幾列:
ISSES_MODIFIABLE VARCHAR2(5) Indicates whether the parameter can be changed withALTER SESSION(TRUE) or not (FALSE)
ISSYS_MODIFIABLE VARCHAR2(9) Indicates whether the parameter can be changed withALTER SYSTEMand when the change takes effect:
IMMEDIATE- Parameter can be changed withALTER SYSTEMregardless of the type of parameter file used to start the instance. The change takes effect immediately.

DEFERRED- Parameter can be changed withALTER SYSTEMregardless of the type of parameter file used to start the instance. The change takes effect in subsequent sessions.

FALSE- Parameter cannot be changed withALTER SYSTEMunless a server parameter file was used to start the instance. The change takes effect in subsequent instances.
 

ISSES_MODIFIABLE 這一列標誌該引數是否可以在session級別被修改;
ISSYS_MODIFIABLE 這一列標誌該引數是否可以在system級別被修改,其中有三個值:
IMMEDIATE表示修改完之後立即生效,DEFERRED表示必須得等下個session才能生效,也就是當前session還是不起作用的,FALSE表示例項重啟後才能生效。
下面就以4個典型引數做實驗:
SQL> select name,ISSES_MODIFIABLE,ISSYS_MODIFIABLE from v$parameter where name in ('workarea_size_policy','audit_file_dest','sga_target','sga_max_size');

NAME                           ISSES_MODIFIABLE               ISSYS_MODIFIABLE
------------------------------ ------------------------------ ----------------------------
workarea_size_policy           TRUE                           IMMEDIATE
sga_target                     FALSE                          IMMEDIATE
audit_file_dest                FALSE                          DEFERRED
sga_max_size                   FALSE                          FALSE

1.workarea_size_policy可以alter session修改

檢視原來的配置:
SQL> show parameter workarea_size_policy

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
workarea_size_policy                 string      AUTO

在session級別修改:
SQL> alter session set workarea_size_policy=MANUAL;

Session altered.

在本session檢視,可以發現修改已經生效:
SQL> show parameter workarea_size_policy

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------
workarea_size_policy                 string      MANUAL

2. sga_target在用alter system修改後立即生效

檢視原來的配置:
SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------------
sga_target                           big integer 1504M

SQL> alter system set sga_target=1400M;

System altered.
用alter system修改後立即生效:
SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------
sga_target                           big integer 1400M

3. audit_file_dest在用alter system修改後,知道下個session才生效

檢視原來的配置:
SQL> show parameter audit_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------
audit_file_dest                      string      H:\INTEL_DB_DUMPS

注意:後面必須得加關鍵字deferred,否則會報錯。
SQL> alter system set audit_file_dest='H:\INTEL_DB_DUMPS\O02DMS1' deferred;

System altered.

在本session裡查詢還是原值,沒有改變:
SQL> show parameter audit_file

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------------
audit_file_dest                      string      H:\INTEL_DB_DUMPS

重新開個session,在查詢發現已經改為新值了:
SQL> show parameter audit_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------------------
audit_file_dest                      string      H:\INTEL_DB_DUMPS\O02DMS1

4. sga_max_size在用alter system修改後必須重啟例項才能生效

檢視原來的配置:
SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------------
sga_max_size                         big integer 1504M

注意:後面必須得加scope=spfile,否則會報錯。
SQL> alter system set sga_max_size=1400 scope=spfile;

System altered.

如果資料庫沒重啟,無論如何還是原來的配置:
SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------
sga_max_size                         big integer 1504M

重啟資料庫:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 1468006400 bytes
Fixed Size                  1303076 bytes
Variable Size             612371932 bytes
Database Buffers          847249408 bytes
Redo Buffers                7081984 bytes
Database mounted.
Database opened.

再重新查詢,就可以看到用的是新值了:
SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------
sga_max_size                         big integer 1400M

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28869493/viewspace-1094171/,如需轉載,請註明出處,否則將追究法律責任。

相關文章