抽出条件付きインポート

(8.0.29)

調べた限り、load data ステートメントで抽出条件は指定できない模様

 

 

(19c)

※抽出条件として、他テーブル参照の場合、
ダンプファイル内のテーブルとインポート先DBのテーブルのどちらを参照しているかを確認する

結論:queryパラメータでimpdp時に条件指定する場合に他テーブルを参照する場合は、インポート先DBのテーブルを参照している

drop table tab1 purge;
drop table tab2 purge;

create table tab1(col1 int primary key,col2 int);
create table tab2(col1 int primary key);

insert into tab1 values(1,100);
insert into tab1 values(2,200);
insert into tab1 values(3,300);
insert into tab1 values(4,400);


insert into tab2 values(100);
insert into tab2 values(200);
insert into tab2 values(800);

commit;

select * from tab1 order by col1;
select * from tab2 order by col1;

expdp test/test@pdb1 directory=ORA_DIR dumpfile=tab1.dmp logfile=tab1.log tables=tab1 reuse_dumpfiles=yes
expdp test/test@pdb1 directory=ORA_DIR dumpfile=tab1tab2.dmp logfile=tab1tab2.log tables=tab1,tab2 reuse_dumpfiles=yes


[1] インポート先DBのテーブルを参照している場合
インポート先DBにtab2がある状態で、下記コマンド実行
impdp test/test@pdb1 directory=ORA_DIR dumpfile=tab1.dmp logfile=tab1.log tables=tab1 \
table_exists_action=replace query=tab1:\"where exists \( select 1 from tab2 where tab2.col1=KU\$.col2\)\"

. . "TEST"."TAB1"                               5.531 KB       2を4行からインポ ートしました

[2] ダンプファイル内のテーブルを参照している場合
インポート先DBのtab2を削除し、下記コマンド実行
impdp test/test@pdb1 directory=ORA_DIR dumpfile=tab1tab2.dmp logfile=tab1.log tables=tab1 \
table_exists_action=replace query=tab1:\"where exists \( select 1 from tab2 where tab2.col1=KU\$.col2\)\"

ORA-31693: 表データ・オブジェクト"TEST"."TAB1"は、ロード/アンロードに失敗し、エ ラーのためスキップされます:
ORA-00942: 表またはビューが存在しません。

 

 

(14)

調べた限り、COPYコマンドでインポート時に抽出条件は指定できない模様

 

(2019)

調べた限り、bcpコマンドでインポート時に抽出条件は指定できない模様