Conventional-path insert(传统路径插入)
前面我们已经说过了Direct-path INSERT
,现在来说一下ConventionalINSERT。文章来源"Oracle® Database Administrator's Guide11g Release 2 (11.2)”
Conventional and Direct-Path INSERT
You can use the INSERT
statement to insert data into a table, partition, or view in two ways: conventionalINSERT
and direct-pathINSERT
. When you issue a conventionalINSERT
statement, Oracle Database reuses free space in the table into which you are inserting and maintains referential integrity constraints. With direct-pathINSERT
, 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-pathINSERT
is the default.
##向表,分区或者视图中插入数据,我们可以使用传统路径插入和直接路径插入两种方式。
当使用传统路径插入方式时,数据库会利用目标表中空闲空间(插入时会扫描高水位线以下,如果有空闲空间就利用,如果没有空闲空间就扩展),并且在插入过程中会维护引用的完整性约束。
当使用直接路径插入时,使用高水位线之上的块。数据绕过buffer cache被直接写入数据文件。目标表中剩余空间不被使用。direct-path INSERT的功能同direct-path loader单元SQL*Loader相似,可以提高insert操作的性能。
当你向一个并行表中插入数据时,默认使用direct-pathINSERT方式。
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
INSERT
always 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.##不论表是否设置了logging模式,数据库是否启用了force logging,数据库是否启用了归档,传统路径插入方式总是会为数据和元数据的变化产生大量的redo和undoDirect-path
INSERT
generates both redo and undo for metadata changes, because these are needed for operation recovery. For data changes, undo and redo are generated as follows:##直接路径插入会为元数据的改变而产生redo和undo,因为这些是进行恢复所需要的信息。对于数据的变化,其所产生的redo和undo根据下面的条件来决定:Direct-path
INSERT
always bypasses undo generation for data changes.##直接路径插入不会产生undo(因为不需要靠undo来回滚)If the database is not in
ARCHIVELOG
orFORCE
LOGGING
mode, then no redo is generated for data changes, regardless of the logging setting of the table. ##如果数据库没有被设置成归档模式,也没有被设置成force logging模式,那么不会为数据的变化产生日志,除非目标表设置了logging模式If the database is in
ARCHIVELOG
mode (but not inFORCE
LOGGING
mode), then direct-pathINSERT
generates data redo forLOGGING
tables but not forNOLOGGING
tables.##如果被设置为归档模式,但是没有被设置我force logging,那么直接路径插入会为指定了logging的表的数据变化产生日志,如果表没有指定logging那么就不产生日志If the database is in
ARCHIVELOG
andFORCE
LOGGING
mode, then direct-path SQL generate data redo for bothLOGGING
andNOLOGGING
tables.##如果数据库处于归档模式,并且设置了force logging,那么不论表是否指定了logging属性,直接路径插入都会为数据变化产生日志
Direct-path INSERT
is subject to a number of restrictions. If any of these restrictions is violated, then Oracle Database executes conventionalINSERT
serially without returning any message, unless otherwise noted:
##Direct-path INSERT有如下一些限制。如果符合下面任何一条,那么数据库会在不给任何反馈信息的情况下自动的采用串行传统路径插入
You can have multiple direct-path
INSERT
statements 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.##在同一个事物中如果有多个direct-pathINSERT
和DML操作,在一个direct-pathINSERT
执行后(提交前)其他的查询或者dml操作都无法执行,执行时会报ORA-12838Queries that access the same table, partition, or index are allowed before the direct-path
INSERT
statement, but not after it.##同上面说的是同一个意思If any serial or parallel statement attempts to access a table that has already been modified by a direct-path
INSERT
in 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
INSERT
is 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.##对于非分区的索引组织表或者是含有mapping table的索引组织表,或者是被视图引用的索引组织表是无法使用直接路径加载的。Direct-path
INSERT
into 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 theAPPEND
orAPPEND_VALUES
hint. However, direct-pathINSERT
operations 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.##当使用Direct-pathINSERT
向单分区或者只有一个分区的索引组织表中插入时,即使索引组织表是使用并行模式建的,也只会使用串行方式插入。但是,只要在使用Direct-pathINSERT向索引组织表中插入数据时,我们没有指定具体的分区扩展名(如 insert into t_part partition(P1) values(1,'***','***')),并且索引组织表有多个分区,我们就可以使用并行模式
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
INSERT
statement cannot be or become distributed.##包含direct-pathINSERT
的事物不能被分布式
You cannot query or modify direct-path inserted data immediately after the insert is complete. If you attempt to do so, anORA-12838
error is generated. You must first issue aCOMMIT
statement before attempting to read or modify the newly-inserted data.
##在同一个事物中如果direct-path inserted执行完成后,提交之前,你不能对目标表进行query以及dml等操作,否则会报ORA-12838错误
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
Using Conventional Inserts to Load Tables
During conventional INSERT operations, the database reuses free space in the table, interleaving newly inserted data with existing data. During such operations, the database also maintains referential integrity constraints. Unlike direct-path INSERT
operations, conventional INSERT
operations do not require an exclusive lock on the table.
Several other restrictions apply to direct-path INSERT
operations that do not apply to conventionalINSERT
operations. SeeOracle Database SQL Language Reference for information about these restrictions.##关于direct-pathINSERT的使用限制上面已经说了
You can perform a conventional INSERT
operation in serial mode or in parallel mode using theNOAPPEND
hint.
##你可以使用NOAPPEND提示来激活串行或者并行模式的conventional INSERT
The following is an example of using the NOAPPEND
hint to perform a conventionalINSERT
in serial mode:
INSERT /*+ NOAPPEND */ INTO sales_hist SELECT * FROM sales WHERE cust_id=8890;
The following is an example of using the NOAPPEND
hint to perform a conventionalINSERT
in parallel mode:
INSERT /*+ NOAPPEND PARALLEL */ INTO sales_histSELECT * FROM sales;
To run in parallel DML mode, the following requirements must be met:
You must have Oracle Enterprise Edition installed.
You must enable parallel DML in your session. To do this, submit the following statement:
ALTER SESSION { ENABLE | FORCE } PARALLEL DML;
You must meet at least one of the following requirements:
Specify the parallel attribute for the target table, either at create time or subsequently
Specify the
PARALLEL
hint for each insert operationSet the database initialization parameter
PARALLEL_DEGREE_POLICY
toAUTO
Conventional-path insert(传统路径插入)相关推荐
- oracle默认导出路径linux,传统路径导出 VS 直接路径导出(oracle exp direct=y)
Oracle 传统的Export与Import依旧被保留到11g,而且9i与10g有很多依旧使用Export与Import方式进行备份与恢复的企业.从Oracle 7.3开始,传统的exp导出程序提供 ...
- python sys.path.append(),sys.path.insert()用法
python sys.path.append(),sys.path.insert()用法 添加import搜索路径 python程序中使用 import XXX 时,python解析器会在当前目录.已 ...
- HTML相对路径(Relative Path)和绝对路径(Absolute Path)
HTML初学者会经常遇到这样一个问题,如何正确引用一个文件.比如,怎样在一个HTML网页中引用另外一个HTML网页作为超链接(hyperlink)?怎样在一个网页中插入一张图片?...... 如果你在 ...
- oracle直接路径读,direct path read直接路径读
前言:传统的数据库读取的方式是先在内存中搜索,如果搜索不到数据,那么就在把数据从磁盘读到内存中,然后PGA再中SGA中获取数据,这样数据就缓存到内存中了,下次再次访问的时候,就可以直接从SGA中获取, ...
- oracle 延迟加载,延迟约束禁止直接路径插入
前两天测试的时候发现了这个现象,如果表中包含了延迟约束,则直接路径插入将转化为常规路径插入. 看一个简单的例子: SQL> CREATE TABLE T (ID NUMBER, NAME VAR ...
- new file https 找不到路径_Python3用pathlib模块替代os.path进行文件路径的操作
本文使用 Zhihu On VSCode 创作并发布 在 Python 3.4 之前和路径相关操作函数都放在 os 模块里面,尤其是os.path这个子模块,可以说os.path模块非常常用.而在 P ...
- php+insert+into+注入,PHP+MySQL之Insert Into数据插入用法分析
本文实例讲述了PHP+MySQL之Insert Into数据插入用法.分享给大家供大家参考.具体如下: INSERT INTO 语句用于向数据库表中插入新纪录. 向数据库表插入数据 INSERT IN ...
- 【Python】Python3.7.3 - sys.path 模块搜索路径详解
文章目录 系统参考 sys.path - 模块搜索路径 用户站点目录(user site directory) 安装包到用户站点目录 第三方站点目录 site.py介绍 python启动选项 PYTH ...
- python import os.path_Python常用模块os.path——文件及路径操作
os.path.abspath(path) 输入相对路径,返回绝对路径 Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1 ...
- mysql中sql批量插入_sql中insert如何批量插入多条记录?
sql中insert如何批量插入多条记录? sql中insert批量插入多条记录的方法: 常见的insert语句,向数据库中,一条语句只能插入一条数据:insert into persons (id_ ...
最新文章
- 算法图解/二分查找/简单查找/选择排序/递归算法/快速排序算法/
- 简单探讨TypeScript 枚举类型
- 基于Kafka+Flink+Redis的电商大屏实时计算案例
- [转]小白都能看懂的softmax详解
- 图论算法(三)--最短路径 的Bellman-Flod [ 带负权值图 ] 的解法(JAVA )
- 天了噜,我国4G用户超过2亿了!
- 插入顶部_最快速地把同一内容插入到Word文档不同页面的相同位置
- 探索 Rust 异步简化编程
- Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(十五)
- History命令的显示带时间
- hdu 1686 Oulipo
- 联想java笔试题20190618
- node文件上传插件formidable的使用
- matlab——非线性规划
- 基于web版kettle开发的用户专业版B/S架构工具
- python使用opencv实现文档扫描并提取文字
- 【数据结构】节点和结点,到底怎么区分?
- 关于C++学习的思考
- mysql5.6安装sys库_编译安装MySQL5.6.23
- RTL8189ES/ETV/FTV系列模块定频软件操作手册