*** Chapter 7
Maintaining Online Redo Log Files
Online Redo Log Files's Characteristics:
1, Record all changes made to data.
2, Provide a recovery mechanism.
3, Can be orgnized into groups.
4, At least two groups required.
A set identical copies of online redo log files called an online
redo log file group.
Each member in a group has identical log sequence numbers and are of the same number.
Multiplexed Redo Log Files : 多路复用.
Log Switch : the act of switching from one log file group to another.
When will LGWR write online redo log file?
when a transaction commits.
Every three seconds.
When the redo log buffer becomes one-thired full.
when there is more than a megabyte of changed records in the redo log buffer.
Before the DBWn writes modified blocks in the Database Buffer Cache to the data files.
LS & LSN
Log Switch
Log Sequence Number
Force Log Switches & Check Point
desc v$log;
select group#, thread#, sequence#,status from v$log;
alter system switch logfile;
Check Point can be forced by
fast_start_mttr_traget=600: 600秒必需发生一次Checkpoint
也就是把脏数据写入数据文件.同时也加快了恢复时间.
show parameter fast_start
alter system set fast_start_mttr_target=300 scope=both;
手动发生check point
alter system checkpoint;
Adding Redo Files Groups
alter database add logfile group 4 ('xx.rdo') size 50M;
alter database add logfile member 'xx.rdo' to group 4;
Dropping Redo File Members.
alter database drop logfile member 'xx.rdo';
Dropping Redo Files Groups.
alter database drop logfile 1;
Relocate & Rename.
alter database rename file command:
shut down the database.
copy to another location.
Clear Redo Files.
alter database clear logfile group 2;
alter database clear unarchived logfile group 2;
Redo File Configuration.
What is Redo Threads?
each database instance referred to as a redo thread.
Archived Redo Log Files.
Filled online redo log files can be archived.
desc v$instance;
select archiver from v$instance;
select log_mode from v$database;
23:26 2009-9-9
Chapter 8 Maintaining Tabspace & Date Files
System tabspace
Non-system tablespace
permanent, undo ,temporary
create tablespace userdata datafile filepath size 5M
select * from v$tablespace;
desc dba_data_files;
select file_name, tablespace_name from dba_data_files;
dbms_space_admin.可改变表空间管理方式.
desc database_properties;
alter tablespace userdata read only;
create tablespace wenchuan
datafile 'd:/wenchuan01.dbf' size 20M
extent management local uniform size 128k;
create user yunchow identified by yunchow default tablespace wenchuan;
grant connect,resource to yunchow;
alter tablespace wenchuan offline;
alter tablespace wenchuan online;
Changing Storage Settings
locally managed tablespaces cannot be altered.
So it is abandoned.
Resizing a Tablespace
alter tablespace wenchuan add datafile
'd:/wenchuan02.dbf' size 20M
autoextend on next 10M maxsize 100M;
alter database datafile 'd:/wenchuan01.dbf'
autoextend on next 10M maxsize 100M;
alter database datafile 'd:/wenchuan01.dbf' resize 10M;
Methods for Moving Datafile
alter tablespace wenchuan rename datafile 'd:/wenchuan02.dbf'
to 'd:/oracle/wenchuan02.dbf';
alter database rename file 'd:/oracle/wenchuan02.dbf'
to 'd:/wenchuan02.dbf';
Dropping Tablespaces
drop tablespace wenchuan including contents and datafiles;
dba_tablespaces
v$tablespace
dba_data_files
v$datafile
dba_temp_files
v$tempfile
Maintaining Online Redo Log Files
Online Redo Log Files's Characteristics:
1, Record all changes made to data.
2, Provide a recovery mechanism.
3, Can be orgnized into groups.
4, At least two groups required.
A set identical copies of online redo log files called an online
redo log file group.
Each member in a group has identical log sequence numbers and are of the same number.
Multiplexed Redo Log Files : 多路复用.
Log Switch : the act of switching from one log file group to another.
When will LGWR write online redo log file?
when a transaction commits.
Every three seconds.
When the redo log buffer becomes one-thired full.
when there is more than a megabyte of changed records in the redo log buffer.
Before the DBWn writes modified blocks in the Database Buffer Cache to the data files.
LS & LSN
Log Switch
Log Sequence Number
Force Log Switches & Check Point
desc v$log;
select group#, thread#, sequence#,status from v$log;
alter system switch logfile;
Check Point can be forced by
fast_start_mttr_traget=600: 600秒必需发生一次Checkpoint
也就是把脏数据写入数据文件.同时也加快了恢复时间.
show parameter fast_start
alter system set fast_start_mttr_target=300 scope=both;
手动发生check point
alter system checkpoint;
Adding Redo Files Groups
alter database add logfile group 4 ('xx.rdo') size 50M;
alter database add logfile member 'xx.rdo' to group 4;
Dropping Redo File Members.
alter database drop logfile member 'xx.rdo';
Dropping Redo Files Groups.
alter database drop logfile 1;
Relocate & Rename.
alter database rename file command:
shut down the database.
copy to another location.
Clear Redo Files.
alter database clear logfile group 2;
alter database clear unarchived logfile group 2;
Redo File Configuration.
What is Redo Threads?
each database instance referred to as a redo thread.
Archived Redo Log Files.
Filled online redo log files can be archived.
desc v$instance;
select archiver from v$instance;
select log_mode from v$database;
23:26 2009-9-9
Chapter 8 Maintaining Tabspace & Date Files
System tabspace
Non-system tablespace
permanent, undo ,temporary
create tablespace userdata datafile filepath size 5M
select * from v$tablespace;
desc dba_data_files;
select file_name, tablespace_name from dba_data_files;
dbms_space_admin.可改变表空间管理方式.
desc database_properties;
alter tablespace userdata read only;
create tablespace wenchuan
datafile 'd:/wenchuan01.dbf' size 20M
extent management local uniform size 128k;
create user yunchow identified by yunchow default tablespace wenchuan;
grant connect,resource to yunchow;
alter tablespace wenchuan offline;
alter tablespace wenchuan online;
Changing Storage Settings
locally managed tablespaces cannot be altered.
So it is abandoned.
Resizing a Tablespace
alter tablespace wenchuan add datafile
'd:/wenchuan02.dbf' size 20M
autoextend on next 10M maxsize 100M;
alter database datafile 'd:/wenchuan01.dbf'
autoextend on next 10M maxsize 100M;
alter database datafile 'd:/wenchuan01.dbf' resize 10M;
Methods for Moving Datafile
alter tablespace wenchuan rename datafile 'd:/wenchuan02.dbf'
to 'd:/oracle/wenchuan02.dbf';
alter database rename file 'd:/oracle/wenchuan02.dbf'
to 'd:/wenchuan02.dbf';
Dropping Tablespaces
drop tablespace wenchuan including contents and datafiles;
dba_tablespaces
v$tablespace
dba_data_files
v$datafile
dba_temp_files
v$tempfile