Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1985528
  • 博文数量: 148
  • 博客积分: 7697
  • 博客等级: 少将
  • 技术积分: 3071
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-10 23:04
个人简介

MiBDP,数据开发、项目团队、数据应用和产品在路上,金融保险、互联网网游、电商、新零售行业、大数据和AI在路上。对数仓、模型、ETL、数据产品应用了解。DTCC 2013演讲嘉宾,曾做过两款大获好评的数据产品平台。知识星球ID:35863277

文章分类
文章存档

2020年(1)

2019年(2)

2017年(2)

2016年(5)

2015年(1)

2014年(1)

2013年(6)

2012年(5)

2011年(24)

2010年(28)

2009年(1)

2008年(6)

2007年(30)

2006年(36)

分类: Oracle

2011-04-11 16:42:50

对于insert语句大家可能都很熟悉了,但对于oracle提供的直接路径的装载(Direct-Path INSERT)还是有很多注意事项的:
比如:直接路径装载不能用于分布式事务 
a:insert /* + append */ into t select * from t@dblink
b:insert /* + append */ into t@dblink select * from t
那么对于a将可以使用直接路径装载 而b语句这个append的hit在此就是多余的了 因为她根本就不会走直接路径的装载
另外对于(Direct-Path INSERT)的注意事项还有一些我们参考下oracle官方的文档记录下:
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:
直接路径装载有很多限制。如果我们违反了这些限制,那么Oracle会按照正常的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.
可以在单独的事务中包括多个直接路径的装载语句或者其他的dml语句。(标红的语句没明白啥意思不知如何翻译)

Queries 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.
不能在相同的事务中通过parallel来访问已经是直接路径装载的表。否则会遭遇:ORA-12838的错误
下例如果没有标红的commit就是这种情况
declare
  v_start_pos paysys_item_info.id%type;
begin
  insert /*+ append */
  into tmp_paysys_item_info
    (Item_ID, Item_Type)
    select Item_ID, Item_Type from paysys_item_info where id >= 25014008;
commit;
  select /*+parallel(t,4)*/
   max(item_id)
    into v_start_pos
    from tmp_paysys_item_info t;
  dbms_output.put_line(v_start_pos);
end;


The target table cannot be index organized or part of a cluster.
目标表不是索引组织表或者是集群的一部分(集群也涉及到分布式)。

The target table cannot contain object type columns.
目标表不能包含对象类型。

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.
最开始的例子,不能用于分布式事务。



阅读(3727) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~