この記事ではアプリケーション・コンテナの管理について解説します。
アプリケーションルートの作成
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートの作成
create pluggable database toys_root as application container admin user admin identified by password role=(connect) create_file_dest='/opt/oracle/oradata';
-- アプリケーションルートのオープン
alter pluggable database toys_root open;
アプリケーションシードの作成
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- アプリケーションシードの作成
create pluggable database as seed admin user admin identified by password role=(connect) create_file_dest='/opt/oracle/oradata';
-- アプリケーションシードのオープン
alter pluggable database toys_root$seed open;
アプリケーションPDBの作成
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- アプリケーションPDBの作成
create pluggable database toys_app1 admin user admin identified by password role=(connect) create_file_dest='/opt/oracle/oradata';
-- アプリケーションPDBのオープン
alter pluggable database toys_app1 open;
シードからアプリケーションPDBの作成
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- シードからアプリケーションPDBの作成
create pluggable database toys_app2 from toys_root$seed;
-- アプリケーションPDBのオープン
alter pluggable database toys_app2 open;
アプリケーションのインストール方法
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- アプリケーションのインストール開始
alter pluggable database application app begin install '1.0';
-- アプリケーションのインストール
@install.sql
-- アプリケーションのインストール終了
alter pluggable database application app end install '1.0';
アプリケーションのアップグレード方法
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- アプリケーションのアップグレード開始
alter pluggable database application app begin upgrade '1.0' to '1.1';
-- アプリケーションのアップグレード
@upgrade.sql
-- アプリケーションのアップグレード終了
alter pluggable database application app end upgrade to '1.1';
アプリケーションPDBへの同期
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- アプリケーションPDB1へ接続
alter session set container=toys_app1;
-- アップグレードの同期
alter pluggable database application app sync;
-- アプリケーションPDB2へ接続
alter session set container=toys_app2;
-- アップグレードの同期
alter pluggable database application app sync;
コンテナマップの作成
## CDBへ接続
sqlplus / as sysdba
-- アプリケーションルートへ接続
alter session set container=toys_root;
-- コンテナマップの作成
create table admin.region_map (region varchar(10)) partition by list(region)
(partition toys_app1 values ('JAPAN','INDIA'),
partition toys_app2 values ('AMERICA','CANADA'));
-- コンテナマップの指定
alter database set container_map='admin.region_map';
-- アプリケーションのアップグレード開始
alter pluggable database application app begin upgrade '1.1' to '1.2';
-- コンテナマップの有効化
alter table admin.sales_data enable container_map;
-- Containers句を省略
alter table admin.sales_data enable containers_default;
-- アプリケーションのアップグレード終了
alter pluggable database application app end upgrade to '1.2';
-- アプリケーションPDB1へ接続
alter session set container=toys_app1;
-- アップグレードの同期
alter pluggable database application app sync;
-- アプリケーションPDB2へ接続
alter session set container=toys_app2;
-- アップグレードの同期
alter pluggable database application app sync;