2
3

More than 1 year has passed since last update.

サポート対象外となったOracle 23c の exp ユーティリティを使ってみた

Posted at

はじめに

Oracle 23c で 元のエクスポート・ユーティリティ(EXP)のサポート終了 が発表され、ユーティリティガイドからも exp に関する記載がなくなっていました。
ちなみに、以前のリリースでも exp 自体は基本的にはサポートされておらず、以下のような例外時にのみサポートされているような状況でした。

ノート:オリジナルのエクスポートは、Oracle Database 11gからは原則としてサポートされなくなりました。Oracle Database 11g以降のリリースでサポートされているオリジナルのエクスポートの使用方法は、XMLTypeデータのOracle Database 10gリリース2 (10.2)以前への下位移行のみです。新しいOracle Data Pumpエクスポートおよびインポート・ユーティリティを使用することをお薦めします。このガイドラインの唯一の例外は、元のエクスポートおよびインポートが必要な次の状況です。

  • オリジナルのエクスポート・ユーティリティ(exp)を使用して作成されたファイルをインポートする必要がある。
  • オリジナルのインポート・ユーティリティ(imp)を使用してインポートされるファイルをエクスポートする必要がある。このような例として考えられるのは、Oracle Database 10gからデータをエクスポートし、それより前のデータベース・リリースにインポートする場合です。

Oracle 23c で実際に 元のexpユーティリティ はどのようになっているのか、一応確認してみました。

元のexpユーティリティ 動作の確認

testusrスキーマにtesttblというテーブルを作成し、ダミーデータを入れます。

testtbl
SQL> select * from testtbl;
        ID TESTCOL
---------- --------------------
         1 hogehoge
         2 hogehogehoge

実際には、23cでも以前と同様にexpユーティリティを利用することができます。
また、Exportユーティリティのリリースも 23 となっています。

23c exp
$ exp testusr/xxxxxxx@ip-xx-xx-xx-xx.ap-northeast-1.compute.internal/FREEPDB1 tables=testtbl;

Export: Release 23.0.0.0.0 - Developer-Release on Fri Jun 9 08:06:26 2023
Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)

About to export specified tables via Conventional Path ...
. . exporting table                        TESTTBL          2 rows exported
Export terminated successfully without warnings.

expしたデータをimpユーティリティでインポートすると、こちらも正常にインポートすることができます。

23c imp
$ imp testusr/xxxxxxx@ip-xx-xx-xx-xx.ap-northeast-1.compute.internal/FREEPDB1 tables=testtbl;

Import: Release 23.0.0.0.0 - Developer-Release on Fri Jun 9 09:46:49 2023
Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0

Export file created by EXPORT:V23.00.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing TESTUSR's objects into TESTUSR
. importing TESTUSR's objects into TESTUSR
. . importing table                      "TESTTBL"          2 rows imported
Import terminated successfully without warnings.

$ sqlplus testusr/xxxxxxx@ip-xx-xx-xx-xx.ap-northeast-1.compute.internal/FREEPDB1
SQL> select * from testtbl;

        ID TESTCOL
---------- --------------------
         1 hogehoge
         2 hogehogehoge

まとめ

23cで 元のexpユーティリティはサポート終了となりましたが、引き続き利用することができるようです。
ただ、例外なくサポート対象外となるため、基本的には expdpへ移行しましょう。

おまけ

元のexp/impユーティリティは、expを実行するクライアントのバージョンでエクスポートダンプファイルのヘッダが決まり、imp時にダンプファイルが上位のバージョンの場合には、IMP-00010エラーが出てimpできません。(例えば、以下のように19cのDBに23cのクライアントからexpしたデータをimpしようとする)

imp時のエラー
$ imp testusr/xxxxxxxx@testdb01.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01 tables=testtbl file=expdat.dmp

Import: Release 21.0.0.0.0 - Production on Fri Jun 9 08:48:54 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.17.0.0.0

IMP-00010: not a valid export file, header failed verification
IMP-00000: Import terminated unsuccessfully

$ cat expdat.dmp
EXPORT:V23.00.00
・・・

例えば、23cのデータベースから21cのexpでexpしたデータは21cのヘッダがつきます。

21cクライアントのexp
$ exp testusr/xxxxxxx@ip-xx-xx-xx-xx.ap-northeast-1.compute.internal/FREEPDB1 tables=testtbl file=exptesttbl-21.dat log=exptesttbl-21.log

Export: Release 21.0.0.0.0 - Production on Fri Jun 9 09:37:46 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)

About to export specified tables via Conventional Path ...
. . exporting table                        TESTTBL          2 rows exported
Export terminated successfully without warnings.

$ cat exptesttbl-21.dat
EXPORT:V21.00.00
・・・

23cのデータベースから23cのexpでexpしたデータは23cのヘッダとなります。

23cクライアントのexp
$ exp testusr/xxxxxxx@ip-xx-xx-xx-xx.ap-northeast-1.compute.internal/FREEPDB1 tables=testtbl;

Export: Release 23.0.0.0.0 - Developer-Release on Fri Jun 9 08:06:26 2023
Version 23.2.0.0.0

Copyright (c) 1982, 2023, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 23c Free, Release 23.0.0.0.0 - Developer-Release
Version 23.2.0.0.0
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses AL32UTF8 character set (possible charset conversion)

About to export specified tables via Conventional Path ...
. . exporting table                        TESTTBL          2 rows exported
Export terminated successfully without warnings.

$ cat expdat.dmp
EXPORT:V23.00.00
・・・

ただ、exp自体もう機能追加等は行われていないので、エディタでヘッダを書き換えると、実はimpできてしまいます。こんなことしちゃダメですよ!

ヘッダ書き換えによる19cへのimp(23cのexpデータ)
$ vi expdat.dmp
 23  19 に変更
$ cat expdat.dmp
EXPORT:V19.00.00

$ imp testusr/xxxxxxxx@testdb01.xxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01 tables=testtbl file=expdat.dmp

Import: Release 21.0.0.0.0 - Production on Fri Jun 9 08:50:48 2023
Version 21.8.0.0.0

Copyright (c) 1982, 2022, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.17.0.0.0

Export file created by EXPORT:V19.00.00 via conventional path
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing TESTUSR's objects into TESTUSR
. importing TESTUSR's objects into TESTUSR
. . importing table                      "TESTTBL"          2 rows imported
Import terminated successfully without warnings.

$ sqlplus testusr/xxxxxxxx@testdb01.xxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com:1521/testdb01
SQL> select * from testtbl;

        ID TESTCOL
---------- --------------------
         1 hogehoge
         2 hogehogehoge
2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3