Oracle中记录/不记录选项的目的是什么 [英] What is the purpose of logging/nologging option in Oracle

查看:95
本文介绍了Oracle中记录/不记录选项的目的是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我未在Oracle中的数据库对象中指定日志记录/不记录日志,该怎么办?我的意思是说在数据库对象中进行日志记录/不记录时,而在数据库对象中不进行日志记录/不记录时会如何表现呢?

What happens if I don't specify logging/nologging in database objects in Oracle? What I meant to say how would behave with logging/nologging in database objects and without logging/nologging in database objects?

推荐答案

LOGGING/NOLOGGING帮助管理启用直接路径写入,以减少REDO和UNDO的产生.这是控制可恢复性和性能之间微妙平衡的几种方法之一.

LOGGING/NOLOGGING helps manage enabling direct path writes in order to reduce the generation of REDO and UNDO. It is one of several ways to control the delicate balance between recoverability and performance.

Oracle体系结构背景信息

REDO 是Oracle提供持久性的方式,即ACID中的"D".提交事务时,更改不必整齐地存储在数据文件中.这样可以使事情保持快速,并让后台进程处理一些工作. REDO是对更改的描述.它以哑"日志的形式快速存储在多个磁盘上.更改速度很快,如果在提交返回后一微秒内服务器掉电,Oracle可以查看REDO日志以确保更改不会丢失.

REDO is how Oracle provides durability, the "D" in ACID. When a transaction is committed the changes are not necessarily stored neatly in the datafiles. That keeps things fast and lets background processes handle some work. REDO is a description of the change. It is stored quickly, on multiple disks, in a "dumb" log. Changes are fast and if the server loses power one microsecond after the commit returned, Oracle can go through the REDO logs to make sure that change isn't lost.

UNDO 帮助Oracle提供一致性,即ACID中的"C".它存储了有关如何撤消更改的描述.正在读取表的另一个进程可能需要此信息,并且需要知道在较早的时间点使用的值是什么.

UNDO helps Oracle provide consistency, the "C" in ACID. It stores a description of how to reverse the change. This information may be needed by another process that's reading the table and needs to know what the value used to be at an older point-in-time.

直接路径写入跳过REDO,UNDO,缓存和其他一些功能,并直接修改数据文件.在许多环境中,这是一个快速但潜在危险的选择,这就是为什么要控制这么多混乱的选择的原因.直接路径写入仅适用于INSERTS,并且仅适用于以下所述的情况.

Direct path writes skip REDO, UNDO, the cache, and some other features, and directly modify data files. This is a fast but potentially dangerous option in many environments, which is why there are so many confusing options to control it. Direct path writes only apply to INSERTS, and only in the scenarios described below.

如果您什么都不做,则默认选项是最安全的日志记录.

If you do nothing the default option is the safest, LOGGING.

控制直接路径写入的多种方式

LOGGING/NOLOGGING是控制直接路径写入的几种选项之一.从 AskTom 了解不同选项如何协同工作:

LOGGING/NOLOGGING is one of several options to control direct path writes. Look at this table from AskTom to understand how the different options all work together:

Table Mode    Insert Mode     ArchiveLog mode      result
-----------   -------------   -----------------    ----------
LOGGING       APPEND          ARCHIVE LOG          redo generated
NOLOGGING     APPEND          ARCHIVE LOG          no redo
LOGGING       no append       ARCHIVE LOG          redo generated
NOLOGGING     no append       ARCHIVE LOG          redo generated
LOGGING       APPEND          noarchive log mode   no redo
NOLOGGING     APPEND          noarchive log mode   no redo
LOGGING       no append       noarchive log mode   redo generated
NOLOGGING     no append       noarchive log mode   redo generated

FORCE LOGGING可以覆盖所有这些设置.可能还有其他一些我不知道的开关.当然,阻止直接路径存在很多限制,例如触发器,外键,集群,索引组织的表等.

FORCE LOGGING can override all those settings. There are probably some other switches I'm not aware of. And of course there are the many limitations that prevent direct path - triggers, foreign keys, cluster, index organized tables, etc.

规则对索引的限制更大.在DML语句期间,索引将总是生成REDO.只有DDL语句(如NOLOGGING索引上的CREATE INDEX ... NOLOGGINGALTER INDEX ... REBUILD)不会生成REDO.

The rules are even more restrictive for indexes. An index will always generate REDO during DML statements. Only DDL statements, like CREATE INDEX ... NOLOGGING or ALTER INDEX ... REBUILD on a NOLOGGING index will not generate REDO.

为什么有这么多方法?由于可恢复性非常重要,因此不同的角色对此问题可能有不同的看法.有时某些人的决定需要超越其他人.

Why are there so many ways? Because recoverability is incredibly important and different roles may have different views on the matter. And sometimes some people's decisions need to override others.

开发人员在语句级别插入模式"中做出决定. /*+ APPEND */提示可能会发生很多奇怪的事情,开发人员需要仔细选择何时使用它.

Developers decide at the statement level, "Insert Mode". Many weird things can happen with an /*+ APPEND */ hint and developers need to choose carefully when to use it.

建筑师在对象级别表模式"下决定.某些表,无论开发人员想要插入到表中的速度如何,都必须始终可恢复.

Architects decide at the object level, "Table Mode". Some tables, regardless of how fast a developer may want to insert into it, must always be recoverable.

数据库管理员在数据库或表空间模式下确定存档日志"和强制日志".也许组织只是不关心恢复特定数据库,所以将其设置为NOARCHIVELOG模式.或者,也许组织有一个严格的规则,即所有内容都必须是可恢复的,因此请将表空间设置为FORCE LOGGING.

Database Administrators decide at the database or tablespace mode, "Archive log" and FORCE LOGGING. Maybe the organization just doesn't care about recovering a specific database, so set it to NOARCHIVELOG mode. Or maybe the organization has a strict rule that everything must be recoverable, so set the tablespace to FORCE LOGGING.

这篇关于Oracle中记录/不记录选项的目的是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆