Oracle 使用引用分区的直接路径插入?

Oracle 使用引用分区的直接路径插入?,oracle,Oracle,如何使用直接路径插入将数据快速加载到具有引用分区的表中?直接路径插入不适用于启用的外键,并且不能禁用引用分区表的外键 SQL> create table parent_table(a number primary key) 2 partition by range(a) (partition p1 values less than (1)); Table created. SQL> create table child_table(a number not null 2

如何使用直接路径插入将数据快速加载到具有引用分区的表中?直接路径插入不适用于启用的外键,并且不能禁用引用分区表的外键

SQL> create table parent_table(a number primary key)
  2  partition by range(a) (partition p1 values less than (1));

Table created.

SQL> create table child_table(a number not null
  2     ,constraint child_table_fk foreign key (a) references parent_table(a))
  3  partition by reference (child_table_fk);

Table created.

SQL> alter table child_table disable constraint child_table_fk;
alter table child_table disable constraint child_table_fk
*
ERROR at line 1:
ORA-14650: operation not supported for reference-partitioned tables

不需要禁用外键。直接路径插入可以使用引用分区,尽管这意味着它不应该使用

下面的加载为选择操作演示了使用直接路径插入:

explain plan for insert /*+ append */ into child_table select 1 from dual;

select * from table(dbms_xplan.display(format => 'basic'));

Plan hash value: 2781518217

--------------------------------------------------------
| Id  | Operation                        | Name        |
--------------------------------------------------------
|   0 | INSERT STATEMENT                 |             |
|   1 |  LOAD AS SELECT                  | CHILD_TABLE |
|   2 |   OPTIMIZER STATISTICS GATHERING |             |
|   3 |    FAST DUAL                     |             |
--------------------------------------------------------

如果直接路径插入不能与引用分区一起工作,那是因为许多其他限制之一,例如触发器、不同的外键、可延迟的限制等。

我想补充一个重要的细节。如果将直接路径插入到引用的分区表中,它不仅会锁定“子”表,还会锁定“父”表