控制文件(control file)中包含了其所属数据库的信息,实例(instance)在启动,及正常工作期间都需要存取这些信息。控制文件的内容只能由Oracle修改,数据库管理员或用户都不应编辑控制文件。
控制文件(control file)中主要包含以下内容:- 数据库名(database name)
- 数据库创建时的时间戳(timestamp)
- 属于此数据库的数据文件(datafile)及重做日志文件(redo log file)的名称与存储位置
- 表空间(tablespace)信息
- 脱机(offline)的数据文件
- 日志历史信息
- 归档日志(archived log)信息
- 备份集(backup set)与备份块(backup piece)信息
- 数据文件与重做日志的备份信息
- 数据文件复制信息
- 当前的日志序列号(log sequence number)
- 检查点(checkpoint)信息
数据库名(database name)和数据库创建时间戳(timestamp)都来源于数据库创建过程。数据库名既可以来自 DB_NAME 初始化参数中的设定值,也可以来自 CREATE DATABASE 语句中的指定值。
- Oracle可以籍此在数据库启动(startup)时识别打开的数据文件和重做日志文件
- Oracle可以籍此在恢复数据库时识别当前可用及需要恢复的文件
因此,用户每次更改数据库的物理结构后(使用 ALTER DATABASE 语句),一定要及时备份控制文件(control file)。
Overview of Control Files
The database control file is a small binary file necessary for the database to start and operate successfully. A control file is updated continuously by Oracle during database use, so it must be available for writing whenever the database is open. If for some reason the control file is not accessible, then the database cannot function properly.
Each control file is associated with only one Oracle database.
Control File Contents
A control file contains information about the associated database that is required for access by an instance, both at startup and during normal operation. Control file information can be modified only by Oracle; no database administrator or user can edit a control file.
Among other things, a control file contains information such as:
The timestamp of database creation
The names and locations of associated datafiles and redo log files
Tablespace information
Datafile offline ranges
The log history
Archived log information
Backup set and backup piece information
Backup datafile and redo log information
Datafile copy information
Checkpoint information
The database name and timestamp originate at database creation. The database name is taken from either the name specified by the DB_NAME initialization parameter or the name used in the CREATE DATABASE statement.
Each time that a datafile or a redo log file is added to, renamed in, or dropped from the database, the control file is updated to reflect this physical structure change. These changes are recorded so that:
Oracle can identify the datafiles and redo log files to open during database startup
Oracle can identify files that are required or available in case database recovery is necessary
Therefore, if you make a change to the physical structure of your database (using ALTER DATABASE statements), then you should immediately make a backup of your control file.
Control files also record information about checkpoints. Every three seconds, the checkpoint process (CKPT) records information in the control file about the checkpoint position in the redo log. This information is used during database recovery to tell Oracle that all redo entries recorded before this point in the redo log group are not necessary for database recovery; they were already written to the datafiles.