简体   繁体   中英

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. Recently we switched to Oracle 19c and cloning doesn't work properly anymore. 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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