1、初始化参数文件
启动实例,会读取初始化参数
(1)spfile (服务器参数文件)二进制文件 不能手动修改 spfile<SID>.ora
sql> show parameter spfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/orcl/spfileorcl.ora
(2)pfile 文本初始化参数文件 手动修改 init<SID>.ora
sql> show parameter pfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/orcl/spfileorcl.ora
初始化参数类型:
派生参数:不建议修改
与操作系统相关的参数:例如 DB_FILE_MULTIBLOCK_READ_COUNT
普通参数:最可能改进系统性能
简化的初始化参数:(30个)
processes 最大用户进程数
undo_tablespace
db_block_size 数据库快大小
高级初始化参数:(300个)
db_cache_size 标准块缓冲区高速缓存大小
read_count
shared_pool_size
#######
control_files 一个或多个控制文件名
动态性能视图:v$parameter
show parameter sga
select name,value from v$parameter where name like '%sga_max_size%';
show sga;
sql> set lines 50;
sql> col name for a50;
sql> select name,value from v$parameter where name like '%sga_max_size%';
NAME
--------------------------------------------------
VALUE
--------------------------------------------------
sga_max_size
7180648448
sql> show parameter sga_max_size
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
sga_max_size big integer 6848M
绑定变量查询:
select name,type,value from v$parameter where name like '%¶meter_name%';
sql> /
Enter value for parameter_name: undo
old 1: select name,value from v$parameter where name like '%¶meter_name%'
new 1: select name,value from v$parameter where name like '%undo%'
NAME TYPE VALUE
------------------------------ ---------- ------------------------------
undo_management ########## AUTO
undo_tablespace ########## UNDOTBS1
undo_retention ########## 900
(3)
静态参数:
只能在参数文件中更改
必须重新启动数据库实例才能生效
动态参数:
会话级别 alter session
系统级别 alter system
session 会话持续期间有效
scope 有如下设置
memory 内存生效
spfile 配置文件有效(需要重启)
both 二者
sql> desc v$parameter;
Name Null? Type
----------------------------------------------------- -------- ----------------------
-------------- NUM NUMBER
NAME VARCHAR2(80)
TYPE NUMBER
VALUE VARCHAR2(4000)
DISPLAY_VALUE VARCHAR2(4000)
ISDEFAULT VARCHAR2(9)
ISSES_MODIFIABLE VARCHAR2(5)
ISSYS_MODIFIABLE VARCHAR2(9)
ISINSTANCE_MODIFIABLE VARCHAR2(5)
ISMODIFIED VARCHAR2(10)
ISADJUSTED VARCHAR2(5)
ISDEPRECATED VARCHAR2(5)
ISBASIC VARCHAR2(5)
DESCRIPTION VARCHAR2(255)
UPDATE_COMMENT VARCHAR2(255)
HASH NUMBER
注意:
ISSES_MODIFIABLE 会话级别更改生效(true/false)
ISSYS_MODIFIABLE 系统级别更改生效(true/false)
ISINSTANCE_MODIFIABLE (true/false)
例子1:
select sysdate from dual;
sql> select ISSES_MODIFIABLE,ISSYS_MODIFIABLE,ISINSTANCE_MODIFIABLE from v$parameter w
here name='nls_date_format';
ISSES ISSYS_MOD ISINS
----- --------- -----
TRUE FALSE FALSE
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss'; //这条命令执行失败
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=memory; //执行失败
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=both; //失败
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=spfile; //执行成功 为啥? 自己思考一下
set lines 100
col name for a30
col ISSES_MODIFIABLE for a15
col ISSYS_MODIFIABLE for a15
col ISINSTANCE_MODIFIABLE for a15
select name,ISSES_MODIFIABLE,ISINSTANCE_MODIFIABLE from v$parameter order by 1;
例子2:
sql> show parameter undo_retention;
NAME TYPE VALUE
------------------------------------ ------------------------------ ------------------------------
undo_retention integer 900
sql> alter system set undo_retention=600 scope=memory;
System altered.
sql> alter system set undo_retention=900 scope=spfile;
System altered.
sql> show parameter undo_retention;
NAME TYPE VALUE
------------------------------------ ------------------------------ ------------------------------
undo_retention integer 600
################################