首页 数据库 mysql教程 Oracle学习.数据文件、控制文件、重做日志文件的理解

Oracle学习.数据文件、控制文件、重做日志文件的理解

Jun 07, 2016 pm 03:24 PM
oracle 什么 学习 控制 数据 文件 日志 理解

什么是数据文件、控制文件、重做日志文件? 首先从Oracle的官方文档里摘录下面内容: The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files, and control files 下面几段内容将解释一

什么是数据文件、控制文件、重做日志文件?


首先从Oracle的官方文档里摘录下面内容:

The following divs explain the physical database structures of an Oracle database, including datafiles, redo log files, and control files

下面几段内容将解释一下,Oracle数据库的物理结构是什么?包括数据文件、控制文件和重做日志文件。

Datafiles


Every Oracle database has one or more physical datafiles. The datafiles contain all the database data. The data of logical database structures, such as tables and indexes, is physically stored in the datafiles allocated for a database.

The characteristics of datafiles are:

  • A datafile can be associated with only one database.

  • Datafiles can have certain characteristics set to let them automatically extend when the database runs out of space.

  • One or more datafiles form a logical unit of database storage called a tablespace.

Data in a datafile is read, as needed, during normal database operation and stored in the memory cache of Oracle. For example, assume that a user wants to access some data in a table of a database. If the requested information is not already in the memory cache for the database, then it is read from the appropriate datafiles and stored in memory.

Modified or new data is not necessarily written to a datafile immediately. To reduce the amount of disk access and to increase performance, data is pooled in memory and written to the appropriate datafiles all at once, as determined by the database writer process (DBWn) background process.

 数据文件:

每一个Oracle数据库都要有一个或者多个物理的数据文件,这些数据文件里存储的就是Oracle数据库里的数据。就好比你有一个文件夹,里面有几个txt的文本文件,文本文件里记录的你这个月的每一笔花销。如果把文件夹看做是数据库,那么txt文件就是数据文件,而txt文件里面记录的每一笔花销就是数据了。

然而表、索引等等其实都是数据库的逻辑结构,这些表、索引都被物理的存储在了数据文件里面。

数据文件有三个特性:

1、一个数据文件只能属于一个数据库。

2、数据库中的数据文件可以被设置成自动的增长。(当数据库的空间用完的时候,数据库中的数据文件就会自动增长,比如原来1G的数据文件自动变成了2G的数据文件)

3、一个或者多个数据文件就组成了数据库的一个逻辑单元叫做---表空间。

(就比如记录流水账,那这个月的账目就组成了一个表空间,下个月的就是另外一个表空间。)

数据文件里的数据,在需要的时候就会被读取到内容Oracle的缓冲区中,比如当我们想查看一天数据时,而这条数据恰好又不在Oracle的缓冲区中,那么Oracle就会把这条数据从数据文件中读取到Oracle的缓冲区中来。

当更改或者新增一天数据时,也不是马上就写到数据文件里面,这么做是为了减少对磁盘的访问,提高效率,数据先存储在缓冲区,然后在一次都写入数据文件,这个过程有一个dbwn后台进程来控制。


Control Files
 
 Every Oracle database has a control file. A control file contains entries that specify the physical structure of the database. For example, it contains the following information:

Database name

Names and locations of datafiles and redo log files

Time stamp of database creation

 Oracle can multiplex the control file, that is, simultaneously maintain a number of identical control file copies, to protect against a failure involving the control file.

 Every time an instance of an Oracle database is started, its control file identifies the database and redo log files that must be opened for database operation to proceed. If the physical makeup of the database is altered (for example, if a new datafile or redo log file is created), then the control file is automatically modified by Oracle to reflect the change. A control file is also used in database recovery.

控制文件:

每一个数据库都拥有控制文件(它和数据文件一样重要),控制文件里记录的是对数据库物理结构的详细信息,例如它包括如下三个信息:
1、数据库的名称
2、数据文件的名字和存在位置,重做日志文件的名字和存储位置
3、数据库创建的时间标识

Oracle可以使用多重的控制文件,也就是说它可以同时维护多个完全一样的控制文件,这么做就是为了防止数据文件损坏而造成的数据库故障。比如Oracle同时维护3个控制文件,当其中有1个控制文件出问题了,就比较好解决,把出问题的删了,在复制一份没有问题的就可以了。

每当Oracle数据库的实例启动的时候,它就会通过控制文件来识别,要想执行数据库的一些操作,必须需要哪些数据文件和重做日志文件,以及这些数据文件和重做日志文件都存在在什么位置。当数据库的物理构成发生改变的时候,比如新增加了一个数据文件或者重做日志文件,那么控制文件就会自动的更新来记录这些变化。另外在数据库恢复的时候也会用到控制文件。


Redo Log Files
 
 Every Oracle database has a set of two or more redo log files. The set of redo log files is collectively known as the redo log for the database. A redo log is made up of redo entries (also called redo records).

 The primary function of the redo log is to record all changes made to data. If a failure prevents modified data from being permanently written to the datafiles, then the changes can be obtained from the redo log, so work is never lost.
 
 To protect against a failure involving the redo log itself, Oracle allows a multiplexed redo log so that two or more copies of the redo log can be maintained on different disks.

 The information in a redo log file is used only to recover the database from a system or media failure that prevents database data from being written to the datafiles. For example, if an unexpected power outage terminates database operation, then data in memory cannot be written to the datafiles, and the data is lost. However, lost data can be recovered when the database is opened, after power is restored. By applying the information in the most recent redo log files to the database datafiles, Oracle restores the database to the time at which the power failure occurred.

 The process of applying the redo log during a recovery operation is called rolling forward.

重做日志文件:
每个Oracle数据库都拥有一组文件,其中包括2个或者多个重做日志文件(其实也可以拥有多组,用途跟多个控制文件一样)。这组文件整体被称为数据库的重做日志,而重做日志又是由一条一条的重做记录组成的,所有也被称为重做记录。
重做日志的主要作用就是记录所有的数据变化,当一个故障导致被修改过的数据没有从内存中永久的写到数据文件里,那么数据的变化是可以从重做日志中获得的,从而保证了对数据修改的不丢失。
为了防止重做日志自身的问题导致故障,所以Oracle拥有多重重做日志功能,也就是可以同时保存多组完全相同的重做日志在不同的磁盘上。
重做日志里的信息只是用于恢复由于系统或者介质故障所引起的数据没法写入数据文件的数据。比如突然断电导致数据库的关闭,那么内存中的数据就不能写入到数据文件中,内存中的数据就会丢失。但当数据库重新启动时丢失的数据是可以被恢复的,可以从最近的重做日志中读取丢失信息然后应用到数据文件中,这样就把数据库恢复到断电前的状态。
在恢复操作中恢复重做日志信息的过程叫做回滚。

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.聊天命令以及如何使用它们
1 个月前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

oracle如何查表空间大小 oracle如何查表空间大小 Apr 11, 2025 pm 08:15 PM

要查询 Oracle 表空间大小,请遵循以下步骤:确定表空间名称,方法是运行查询:SELECT tablespace_name FROM dba_tablespaces;查询表空间大小,方法是运行查询:SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

oracle视图如何加密 oracle视图如何加密 Apr 11, 2025 pm 08:30 PM

Oracle 视图加密允许您加密视图中的数据,从而增强敏感信息安全性。步骤包括:1) 创建主加密密钥 (MEk);2) 创建加密视图,指定要加密的视图和 MEk;3) 授权用户访问加密视图。加密视图工作原理:当用户查询加密视图时,Oracle 使用 MEk 解密数据,确保只有授权用户可以访问可读数据。

oracle如何查看实例名 oracle如何查看实例名 Apr 11, 2025 pm 08:18 PM

在 Oracle 中查看实例名的方法有三种:命令行中使用 "sqlplus" 和 "select instance_name from v$instance;" 命令。在 SQL*Plus 中使用 "show instance_name;" 命令。通过操作系统的任务管理器、Oracle Enterprise Manager 或检查环境变量 (Linux 上的 ORACLE_SID)。

Oracle安装失败如何卸载 Oracle安装失败如何卸载 Apr 11, 2025 pm 08:24 PM

Oracle 安装失败的卸载方法:关闭 Oracle 服务,删除 Oracle 程序文件和注册表项,卸载 Oracle 环境变量,重新启动计算机。若卸载失败,可使用 Oracle 通用卸载工具手动卸载。

oracle如何获取时间 oracle如何获取时间 Apr 11, 2025 pm 08:09 PM

在 Oracle 中获取时间有以下方法:CURRENT_TIMESTAMP:返回当前系统时间,精确到秒。SYSTIMESTAMP:比 CURRENT_TIMESTAMP 更准确,精确到纳秒。SYSDATE:返回当前系统日期,不含时间部分。TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS'): 将当前系统日期和时间转换为特定格式。EXTRACT:从时间值中提取特定部分,如年份、月份或小时。

oracle数据库如何导入 oracle数据库如何导入 Apr 11, 2025 pm 08:06 PM

数据导入方法:1. 使用 SQLLoader 实用程序:准备数据文件、创建控制文件、运行 SQLLoader;2. 使用 IMP/EXP 工具:导出数据、导入数据。提示:1. 大数据集推荐 SQL*Loader;2. 目标表应存在,列定义匹配;3. 导入后需验证数据完整性。

oracle怎么循环创建游标 oracle怎么循环创建游标 Apr 12, 2025 am 06:18 AM

Oracle 中,FOR LOOP 循环可动态创建游标, 步骤为:1. 定义游标类型;2. 创建循环;3. 动态创建游标;4. 执行游标;5. 关闭游标。示例:可循环创建游标,显示前 10 名员工姓名和工资。

oracle如何设置用户 oracle如何设置用户 Apr 11, 2025 pm 08:21 PM

在 Oracle 中创建用户需遵循以下步骤:使用 CREATE USER 语句创建新用户。使用 GRANT 语句授予必要权限。可选:使用 RESOURCE 语句设置配额。配置其他选项,如默认角色和临时表空间。

See all articles