-- 1. コンパートメント作成
oci iam compartment create \
--compartment-id ocid1.tenancy.oc1..111111111111111111111111111111111111111111111111111111111111 \
--description cmp01 \
--name cmp01
oci iam compartment list \
--query 'data[?"name"==`'cmp01'`].id | [0]' \
--raw-output
-- 2. ADW作成
oci db autonomous-database list \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111
oci db autonomous-database list \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111 \
--display-name adb11
oci db autonomous-database create \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111 \
--admin-password 'passwordpassword' \
--backup-retention-period-in-days 1 \
--character-set AL32UTF8 \
--compute-count 2 \
--compute-model ECPU \
--data-storage-size-in-tbs 1 \
--db-name adb11 \
--db-version 19c \
--db-workload DW \
--display-name adb11 \
--is-auto-scaling-enabled FALSE \
--is-auto-scaling-for-storage-enabled FALSE \
--license-model LICENSE_INCLUDED \
--ncharacter-set AL16UTF16 \
--is-local-data-guard-enabled FALSE \
--is-mtls-connection-required FALSE \
--whitelisted-ips '[
"192.0.2.1"
]'
★Always Freeの場合
oci db autonomous-database create \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111 \
--admin-password 'passwordpassword' \
--db-name adb12 \
--db-version 19c \
--db-workload DW \
--display-name adb12 \
--is-auto-scaling-enabled FALSE \
--is-auto-scaling-for-storage-enabled FALSE \
--is-local-data-guard-enabled FALSE \
--is-mtls-connection-required FALSE \
--whitelisted-ips '[
"192.0.2.1"
]' \
--is-free-tier TRUE
oci db autonomous-database stop \
--autonomous-database-id ocid1.autonomousdatabase.oc1.iad.111111111111111111111111111111111111111111111111111111111111
oci db autonomous-database start \
--autonomous-database-id ocid1.autonomousdatabase.oc1.iad.111111111111111111111111111111111111111111111111111111111111
oci db autonomous-database list \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111 \
--query 'data[].{"db-name":"db-name","id":"id","lifecycle-state":"lifecycle-state"}' \
--output table
-- 3. クレデンシャル・ウォレットで接続
https://oracle-japan.github.io/ocitutorials/database/adb104-connect-using-wallet/
※デフォルトポートは1522
cd
rm -rf client_credentials
mkdir client_credentials
unzip Wallet_adb11.zip -d client_credentials
export TNS_ADMIN=~/client_credentials
cd ~/client_credentials
vim sqlnet.ora
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="?/network/admin")))
↓
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY=$TNS_ADMIN)))
sqlplus admin/passwordpassword@adb11_low
-- 4. クリーンアップ
oci db autonomous-database list \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111 \
--query 'data[?"db-name"==`'adb11'`]."id" | [0]' \
--raw-output
oci db autonomous-database delete \
--autonomous-database-id ocid1.autonomousdatabase.oc1.iad.111111111111111111111111111111111111111111111111111111111111 \
--force
oci iam compartment list \
--query 'data[?"name"==`'cmp01'`].id | [0]' \
--raw-output
oci iam compartment delete \
--compartment-id ocid1.compartment.oc1..111111111111111111111111111111111111111111111111111111111111 \
--force