官方如是说:
Controlling the Writing of Redo Records
For some database operations, you can control whether the database generates redo records. Without redo, no media recovery is possible. However, suppressing redo generation can improve performance, and may be appropriate for easily recoverable operations. An example of such an operation is a CREATE TABLE...AS SELECT statement, which can be repeated in case of database or instance failure.
Specify the NOLOGGING clause in the CREATE TABLESPACE statement to suppress redo when these operations are performed for objects within the tablespace. If you do not include this clause, or if you specify LOGGING instead, then the database generates redo when changes are made to objects in the tablespace. Redo is never generated for temporary segments or in temporary tablespaces, regardless of the logging attribute.
The logging attribute specified at the tablespace level is the default attribute for objects created within the tablespace. You can override this default logging attribute by specifying LOGGING or NOLOGGINGat the schema object level--for example, in a CREATE TABLE statement.
If you have a standby database, NOLOGGING mode causes problems with the availability and accuracy of the standby database. To overcome this problem, you can specify FORCE LOGGING mode. When you include the FORCE LOGGING clause in the CREATE TABLESPACE statement, you force the generation of redo records for all operations that make changes to objects in a tablespace. This overrides any specification made at the object level.
If you transport a tablespace that is in FORCE LOGGING mode to another database, the new tablespace will not maintain the FORCE LOGGING mode.
Conventional and Direct-Path INSERT
You can use the INSERT statement to insert data into a table, partition, or view in two ways: conventional INSERT and direct-path INSERT. When you issue a conventional INSERT statement, Oracle Database reuses free space in the table into which you are inserting and maintains referential integrity constraints. With direct-path INSERT, the database appends the inserted data after existing data in the table. Data is written directly into data files, bypassing the buffer cache. Free space in the existing data is not reused. This alternative enhances performance during insert operations and is similar to the functionality of the Oracle direct-path loader utility, SQL*Loader. When you insert into a table that has been created in parallel mode, direct-path INSERT is the default.
The manner in which the database generates redo and undo data depends in part on whether you are using conventional or direct-path INSERT:
-
Conventional
INSERTalways generates maximal redo and undo for changes to both data and metadata, regardless of the logging setting of the table and the archivelog and force logging settings of the database. -
Direct-path
INSERTgenerates both redo and undo for metadata changes, because these are needed for operation recovery. For data changes, undo and redo are generated as follows:-
Direct-path
INSERTalways bypassesundo generation for data changes. -
If the database is not in
ARCHIVELOGorFORCELOGGINGmode, then no redo is generated for data changes, regardless of the logging setting of the table. -
If the database is in
ARCHIVELOGmode (but not inFORCELOGGINGmode), then direct-pathINSERTgenerates data redo forLOGGINGtables but not forNOLOGGINGtables. -
If the database is in
ARCHIVELOGandFORCELOGGINGmode, then direct-path SQL generate data redo for bothLOGGINGandNOLOGGINGtables.
-
Direct-path INSERT is subject to a number of restrictions. If any of these restrictions is violated, then Oracle Database executes conventional INSERT serially without returning any message, unless otherwise noted:
-
You can have multiple direct-path
INSERTstatements in a single transaction, with or without other DML statements. However, after one DML statement alters a particular table, partition, or index, no other DML statement in the transaction can access that table, partition, or index. -
Queries that access the same table, partition, or index are allowed before the direct-path
INSERTstatement, but not after it. -
If any serial or parallel statement attempts to access a table that has already been modified by a direct-path
INSERTin the same transaction, then the database returns an error and rejects the statement. -
The target table cannot be of a cluster.
-
The target table cannot contain object type columns.
-
Direct-path
INSERTis not supported for an index-organized table (IOT) if it is not partitioned, if it has a mapping table, or if it is reference by a materialized view. -
Direct-path
INSERTinto a single partition of an index-organized table (IOT), or into a partitioned IOT with only one partition, will be done serially, even if the IOT was created in parallel mode or you specify theAPPENDorAPPEND_VALUEShint. However, direct-pathINSERToperations into a partitioned IOT will honor parallel mode as long as the partition-extended name is not used and the IOT has more than one partition. -
The target table cannot have any triggers or referential integrity constraints defined on it.
-
The target table cannot be replicated.
-
A transaction containing a direct-path
INSERTstatement cannot be or become distributed.
You cannot query or modify direct-path inserted data immediately after the insert is complete. If you attempt to do so, an ORA-12838 error is generated. You must first issue a COMMIT statement before attempting to read or modify the newly-inserted data.
See Also:
-
Oracle Database Administrator's Guide for a more complete description of direct-path
INSERT -
Oracle Database Utilities for information on SQL*Loader
-
Oracle Database Performance Tuning Guide for information on how to tune parallel direct-path
INSERT
总结:
1. Nologging是对象的一种属性,只能对该对象设置属性为Nologging或Logging,不能动态设置执行某一条语句时使用Nologging或Logging .Nologging可以是DATABASE级别的,也可以是TABLESPACE级别的,也可以是TABLE级别的.在"CREATE DATABASE","CREATE TABLESPACE","CREATE TABLE"的同时可以指定该属性,但该属性最终作用的对象是table或index.
2. Force Logging属性打开时,任何其它的属性都会被覆盖,此时会强制写REDO信息.
3. Nologging的最终作用对象是table或index,最终起效的操作仅仅为"Direct-Path insert".其它操作,如"update, delete",该选项均无效.
Oracle数据库允许控制redo记录的生成,Nologging特性能提升性能,但可能影响可恢复性。Nologging适用于如INSERT语句等可重复操作。在表空间级别设置Nologging是对象的默认属性,但可被对象级别设置覆盖。在备用数据库中,Nologging可能导致问题,可以使用NOFORCE模式。Direct-Path INSERT是高效的插入方式,不生成数据的undo信息,但在特定数据库模式下会生成redo记录。该操作受一些限制,并且在插入后无法立即查询或修改数据。
300

被折叠的 条评论
为什么被折叠?



