前回→[RDSへのデータ移行]1.SCT(AWS Schema Conversion Tool)の設定
1.スキーマ変換
- 変換対象スキーマを右クリックしConvert schemaをクリック
![17.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2F8af6f8f9-aadd-a846-ec52-af1267ff4e06.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=0c3ad2ffe908de88c9837149740af9e9)
![18.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2F2bc4305b-0e6a-d999-ce57-7509a05291ff.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=d260cad28928546624651f20199e2c78)
![19.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2F559cfbf6-4812-ba88-dbfc-866f3704170a.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=38ad67efdd19681792ff704139de798c)
![20.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2F5665f5d3-6ea6-2b58-d950-e85967e2658a.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=77e1bce1b2f063cc0f3bb6c13b9b53ae)
![21.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2Fd8422a8a-9feb-1a5e-4a3b-5afa6816d2fd.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=40ac0109631f77b509efd9567f176451)
![22.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2Fa85e0e50-a62c-a9a8-a8a8-d0a1e9a88284.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=ea0b37b51cd57f71d1a193972a9ae68d)
![23.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.ap-northeast-1.amazonaws.com%2F0%2F449014%2Fa6f23f1d-3820-5ed7-f0d9-5d61073d3a23.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=49027da94afb3e5cff761278d5e4bc5c)
2.スキーマの確認
- Aurora(PostgresSQL)にログインしSCOTTを確認
-- クラスタにログイン
$ sudo psql --host=targetdb-cluster.cluster-xxxx.ap-northeast-1.rds.amazonaws.com --port=5432 --username=postgres --password --dbname=targetdb
ユーザ postgres のパスワード:
psql (9.2.24, サーバー 10.7)
注意: psql バージョン 9.2, サーバーバージョン 10.0.
psql の機能の中で、動作しないものがあるかもしれません。
SSL 接続 (暗号化方式: ECDHE-RSA-AES256-GCM-SHA384, ビット長: 256)
"help" でヘルプを表示します.
targetdb=>
targetdb=>
-- DB一覧を確認
targetdb=> \l
データベース一覧
名前 | 所有者 | エンコーディング | 照合順序 | Ctype(変換演算子) | アクセス権
-----------+----------+------------------+-------------+-------------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
rdsadmin | rdsadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | rdsadmin=CTc/rdsadmin
targetdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | rdsadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/rdsadmin +
| | | | | rdsadmin=CTc/rdsadmin
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 行)
targetdb=>
-- 現在の実行ユーザの確認
targetdb=> select current_user;
current_user
--------------
postgres
(1 行)
-- 現在の実行スキーマの確認
targetdb=> select current_schema();
current_schema
----------------
public
(1 行)
-- スキーマ一覧確認
targetdb=> \dn
スキーマ一覧
名前 | 所有者
--------------------+----------
aws_oracle_context | postgres
aws_oracle_data | postgres
aws_oracle_ext | postgres
public | postgres
scott | postgres
(5 行)
-- スキーマ切り替え(public → scott)
targetdb=> SET search_path = scott;
SET
targetdb=>
-- 現在の実行スキーマの確認
targetdb=> select current_schema();
current_schema
----------------
scott
(1 行)
-- テーブル一覧確認
targetdb=> \dt;
リレーションの一覧
スキーマ | 名前 | 型 | 所有者
----------+------+----------+----------
scott | tbl1 | テーブル | postgres
(1 行)
-- テーブル内のデータを確認
targetdb=> select * from tbl1;
id | txt
----+-----
(0 行)
-- 接続断
targetdb=> \q
$
- SCOTTとSCOTTのオブジェクト(tbl1表)を確認できた