11
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

APEX:SQLclでアプリケーションをエクスポートしてみる

Last updated at Posted at 2025-06-12

はじめに

Oralce APEXで作成したアプリケーションは開発画面からGUIで簡単にエクスポートすることができますが、今回はSQLclを使ってエクスポートしてみました。SQLclを使用することで、アプリケーションのエクスポート/インポートをスクリプト処理に組み込むことができます。

基本的には以下のドキュメントを参考にしています。
3.12.11.1 SQLclを使用したエクスポートとインポート

ADBのWallet取得

APEXを作成しているデータベース(今回はADB)のWalletを取得しておきます。
OCIコンソールの「データベース接続」から.zipをダウンロードします。

SQLclのインストール

Oracle Linuxのインスタンスを使用します。
opcユーザーでSSHログインします。

Javaのインストール

sudo yum install -y java-11-openjdk

インストール確認:

java -version

SQLclのダウンロード

cd ~
wget https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip

SQLclを解凍

unzip sqlcl-latest.zip -d sqlcl

実行確認

[opc@ol ~]$ ~/sqlcl/bin/sql -v

SQLcl: Release 25.1.1.0 Production Build: 25.1.1.113.2054

ADBへ接続

Walletのコピー

ローカルからscpでADB接続ウォレットをインスタンスへ転送します。

WalletZIPファイルの解凍

mkdir ~/wallet
unzip ~/Wallet_<DB名>.zip -d ~/wallet
[opc@ol ~]$ unzip ~/Wallet_apexaioac.zip -d ~/wallet
Archive:  /home/opc/Wallet_apexaioac.zip
  inflating: /home/opc/wallet/ewallet.pem
  inflating: /home/opc/wallet/README
  inflating: /home/opc/wallet/cwallet.sso
  inflating: /home/opc/wallet/tnsnames.ora
  inflating: /home/opc/wallet/truststore.jks
  inflating: /home/opc/wallet/ojdbc.properties
  inflating: /home/opc/wallet/sqlnet.ora
  inflating: /home/opc/wallet/ewallet.p12
  inflating: /home/opc/wallet/keystore.jks
[opc@ol ~]$

sqlnet.oraでWalletの場所を指定

sqlnet.ora をテキストエディタで開いて修正します。

vi ~/wallet/sqlnet.ora

以下のとおり、「DIRECTORY=」のパスを修正します。

修正後
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="/home/opc/wallet")))
SSL_SERVER_DN_MATCH=yes

SQLcl を起動

パスワードを求められるので、データベースのAdminユーザーのパスワードを入力します。

[opc@ol ~]$ cd ~/sqlcl/bin
[opc@ol bin]$ ./sql -cloudconfig /home/opc/Wallet2_apexaioac.zip admin@apexaioac_medium


SQLcl: Release 25.1 Production on Thu Jun 12 07:18:24 2025

Copyright (c) 1982, 2025, Oracle.  All rights reserved.

Password? (**********?) ***************
Last Successful login time: Thu Jun 12 2025 07:18:31 +00:00

Connected to:
Oracle Database 23ai Enterprise Edition Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems
Version 23.8.0.25.06

APEXアプリケーションのエクスポート

ワークスペース内の情報を確認

ワークスペース内のアプリケーション情報を確認できます。

SQL> apex list
WORKSPACE_ID        WORKSPACE                     APPLICATION_ID    APPLICATION_NAME                                            BUILD_STATUS       LAST_UPDATED_ON  LAST_UPDATED_BY
10                  INTERNAL                      4000              Oracle APEX App Builder                                     Run and Develop    31-MAY-25
10                  INTERNAL                      4020              Oracle APEX Create App Wizard    



エクスポートするアプリケーションIDを確認して、以下のとおりエクスポートできます。

特定のアプリケーションIDを指定してエクスポートする

SQL> apex export -applicationid 1234

ワークスペースからすべてのアプリケーションをエクスポートする

SQL> apex export -workspaceid 1908816359534887

Exporting Application 106:'Sample Interactive Grids'
Exporting Application 110:'Books with Tags'
Exporting Application 113:'List Examples'
Exporting Application 117:'HR App'

ワークスペースをエクスポートする

ワークスペースIDを指定して特定のワークスペースをエクスポートします

SQL> apex export -expWorkspace -workspaceId 7849112755431091
Exporting Workspace 7849112755431091:'AI_SEARCH'
File w7849112755431091.sql created


11
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
11
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?