Data Pumpも癖モノだよね〜w その1 - queryパラメーターの解析タイミング Tweet
AWS、MS、Oracle、それぞれのクラウド環境へのデータ移行なんてことも珍しくなくなってきました。
そして移行ツールとしても利用されるData Pump。
でも細かい機能を使おうと調べていると、Data Pump、いろいろ癖があるよなぁ〜。と改めて気づくんですw
ということで、そんな癖もの! Data PumpのFAQっぽいことを備忘録として書いておきますね。(要するに、ハマったこと集w)
queryパラメータに記述したwhere句っていつ解析されるかご存知ですか?
expdpコマンドを実行した時点でqueryパラメータのwhere句のシンタックスがチェックされると思う方、手をあげて!
私もそう思ってました、最近までw
あえて書いてるのですから、勘の良いかたなら、ちがうのか! と気づいちゃいますよねw
そう!ちがうんです!
では、シンタックスエラーのあるqueryパラメータで実行してみますよ。 赤字の部分、where であるべきですが、 while としてあります。パースされればシンタックスエラーとなるはずです!!
いいですか〜〜〜、よ〜〜〜〜く見ててくださいよ〜。みて、みて、みてみてみてみて〜〜〜〜っ
パラメータファイルは以下のとおり
[oracle@crayfish ˜]$ cat query.par
tables=hoge
query=hoge:"while id = 1"
実行してみると、あーら不思議、正常終了してしまいます!
[oracle@crayfish ˜]$ expdp hr/hr@orcl directory=homedir dumpfile=testhr_query45.dmp logfile=testhr_query45.log parfile=query.par
Export: Release 12.1.0.2.0 - Production on Sat Apr 8 00:34:48 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "HR"."SYS_EXPORT_TABLE_01": hr/********@orcl directory=homedir dumpfile=testhr_query45.dmp logfile=testhr_query45.log parfile=query.par
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
. . exported "HR"."HOGE" 0 KB 0 rows
Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TABLE_01 is:
/home/oracle/testhr_query45.dmp
Job "HR"."SYS_EXPORT_TABLE_01" successfully completed at Sat Apr 8 00:35:13 2017 elapsed 0 00:00:24
なぜなのかわかりますか????
queryパラメータでデータを選択する対象の表が空だと、queryパラメータに指定したwhere句はパースされない!
そもそも取り出すデータが無いので無駄なことはしない!
ということのようです。
ということで、queryパラメータのシンタックスチェックだけを事前に行いたい場合、1行以上のデータが必要でっす!
0件の状態で実行してもqueryパラメータのシンタックスチェックにはならないのでご注意を!!
[oracle@crayfish ˜]$ sqlplus hr/hr@orcl
SQL*Plus: Release 12.1.0.2.0 Production on Sat Apr 8 00:36:29 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Sat Apr 08 2017 00:34:48 +09:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
orcl@HR> insert into hoge values(1,'test');
1 row created.
orcl@HR> commit;
Commit complete.
orcl@HR> select count(1) from hoge;
COUNT(1)
----------
1
空の表に1行だけデータを登録すると! queryパラメターのwhere句が解析されシンタックスエラーとなります!
[oracle@crayfish ˜]$ cat query.par
tables=hoge
query=hoge:"while id = 1"
[oracle@crayfish ˜]$
[oracle@crayfish ˜]$ expdp hr/hr@orcl directory=homedir dumpfile=testhr_query46.dmp logfile=testhr_query46.log parfile=query.par
Export: Release 12.1.0.2.0 - Production on Sat Apr 8 00:37:08 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
Starting "HR"."SYS_EXPORT_TABLE_01": hr/********@orcl directory=homedir dumpfile=testhr_query46.dmp logfile=testhr_query46.log parfile=query.par
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
ORA-31693: Table data object "HR"."HOGE" failed to load/unload and is being skipped due to error:
ORA-00933: SQL command not properly ended
Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for HR.SYS_EXPORT_TABLE_01 is:
/home/oracle/testhr_query46.dmp
Job "HR"."SYS_EXPORT_TABLE_01" completed with 1 error(s) at Sat Apr 8 00:37:34 2017 elapsed 0 00:00:24
ということで本日はここまで。
| 固定リンク | 0
コメント