简体   繁体   English

在 Oracle 19c 中使用 DBMS_DATAPUMP 克隆模式会使索引组织表为空

[英]Cloning a schema in Oracle 19c with DBMS_DATAPUMP leaves index organized tables empty

When using scripts for cloning a schema from this or this source, it works perfectly ok in Oracle 11g we are using.当使用脚本从这个这个源克隆模式时,它在我们正在使用的 Oracle 11g 中运行良好。 Recently we switched to Oracle 19c and cloning doesn't work properly anymore.最近我们切换到 Oracle 19c 并且克隆不再正常工作。 While, at first glance, everything looks ok, on closer inspection, index organized tables are empty.乍一看,一切看起来都不错,但仔细观察,索引组织的表是空的。 When I checked the structure of these tables, indexes and constraints were missing.当我检查这些表的结构时,缺少索引和约束。

The example of index organized table in the source schema:源模式中索引组织表的示例:

CREATE TABLE some_table
(
    id1    INTEGER NOT NULL,
    id2    INTEGER NOT NULL,
    CONSTRAINT pk_some_table PRIMARY KEY (id1, id2) ENABLE VALIDATE
)
ORGANIZATION INDEX
/

CREATE INDEX ix_some_table_01
    ON some_table (id1)
/

CREATE INDEX ix_some_table_02
    ON some_table (id2)
/

ALTER TABLE some_table
    ADD (CONSTRAINT fk_some_table_01 FOREIGN KEY (id1) REFERENCES parent_table1 (id) ENABLE VALIDATE)
/

ALTER TABLE some_table
    ADD (CONSTRAINT fk_some_table_02 FOREIGN KEY (id2) REFERENCES parent_table2 (id) ENABLE VALIDATE)
/

And the same table in the destination (cloned) schema:以及目标(克隆)模式中的同一张表:

CREATE TABLE some_table
(
    id1    INTEGER NOT NULL,
    id2    INTEGER NOT NULL,
    CONSTRAINT pk_some_table PRIMARY KEY (id1, id2) ENABLE VALIDATE
)
ORGANIZATION INDEX
/

And, as I mentioned, no data is cloned and cloned index organized tables are left empty.而且,正如我所提到的,没有数据被克隆,克隆的索引组织表是空的。 I suspect that cloning procedure tries to create constraints (using indexes) before indexes themselves and it fails, but I'm not sure that this is the cause.我怀疑克隆过程试图在索引本身之前创建约束(使用索引)并且它失败了,但我不确定这是不是原因。

Any help would be appreciated.任何帮助,将不胜感激。 Thanks!谢谢!

Thanks for using my script :-) but sorry I can't reproduce in 19.14感谢您使用我的脚本 :-) 但很抱歉我无法在 19.14 中重现

SQL> create user demo identified by demo quota 100m on users;

User created.

SQL> grant create session to demo;

Grant succeeded.

SQL> grant create table to demo;

Grant succeeded.

SQL> grant create cluster to demo;

Grant succeeded.

SQL> grant create sequence to demo;

Grant succeeded.

SQL> grant create procedure to demo;

Grant succeeded.

SQL> grant create trigger to demo;

Grant succeeded.

SQL> grant create type to demo;

Grant succeeded.

SQL> grant create operator to demo;

Grant succeeded.

SQL> grant create indextype to demo;

Grant succeeded.

SQL> create table demo.iot (
  2   empno primary key
  3  ,ename
  4  ,job
  5  ,mgr
  6  ,hiredate
  7  ,sal
  8  ,comm
  9  ,deptno
 10  )
 11  organization index
 12  as select * from scott.emp;

Table created.

SQL>
SQL> create table demo.heap (
  2   empno primary key
  3  ,ename
  4  ,job
  5  ,mgr
  6  ,hiredate
  7  ,sal
  8  ,comm
  9  ,deptno
 10  )
 11  as select * from scott.emp;

Table created.

SQL> set serverout on
SQL> exec clone_schema('DEMO','DEMO2',p_drop_new=>false);
173413:Starting job
173601:Final state:COMPLETED
Starting "MCDONAC"."DEMO_SCHEMA_IMP":
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
. . imported "DEMO2"."HEAP"                                  14 rows
. . imported "DEMO2"."IOT"                                   14 rows
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "MCDONAC"."DEMO_SCHEMA_IMP" successfully completed at Fri Jun 3 17:35:00 2022 elapsed 0 00:00:47

PL/SQL procedure successfully completed.

SQL> select count(*) from demo2.heap;

  COUNT(*)
----------
        14

SQL> select count(*) from demo2.iot;

  COUNT(*)
----------
        14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM