Importing data from Db2 to Amazon RDS for Db2 with the INSERT command
You can use the INSERT command from a self-managed Db2 server to insert your
data into an Amazon RDS for Db2 database. With this migration approach, you use a nickname for the
remote RDS for Db2 DB instance. Your self-managed Db2 database (source) must be able to connect
to the RDS for Db2 database (target).
Important
The INSERT command method is useful for migrating small tables. If your
network bandwidth between your self-managed Db2 database and RDS for Db2 database is
limited, we recommend that you use a different migration approach. For more information,
see Using native Db2 tools to migrate data from Db2 to Amazon RDS for Db2.
To copy data from a self-managed Db2 database to an RDS for Db2 database
-
Catalog the RDS for Db2 DB instance on the self-managed Db2 instance.
-
Catalog the node. In the following example, replace
dns_ip_addressandportwith the DNS name or the IP address and the port number of the self-managed Db2 database.db2 catalog tcpip node remnode REMOTEdns_ip_addressSERVERport -
Catalog the database. In the following example, replace
rds_database_namewith the name of the database on your RDS for Db2 DB instance.db2 catalog databaserds_database_nameas remdb at node remnode \ authentication server_encrypt
-
-
Enable federation on the self-managed Db2 instance. In the following example, replace
source_database_namewith the name of your database on the self-managed Db2 instance.db2 update dbm cfg using FEDERATED YESsource_database_name -
Create tables on the RDS for Db2 DB instance.
-
Catalog the node. In the following example, replace
dns_ip_addressandportwith the DNS name or the IP address and the port number of the self-managed Db2 database.db2 catalog tcpip node srcnode REMOTEdns_ip_addressserverport -
Catalog the database. In the following example, replace
source_database_nameandsource_database_aliaswith the name of the self-managed Db2 database and the alias that you want to use for this database.db2 catalog databasesource_database_nameassource_database_aliasat node srcnode \ authentication server_encrypt
-
-
Attach to the source database. In the following example, replace
source_database_alias,user_id, anduser_passwordwith the alias that you created in the previous step and the user ID and password for the self-managed Db2 database.db2look -dsource_database_alias-iuser_id-wuser_password-e -l -a -f -wlm \ -cor -createdb -printdbcfg -o db2look.sql -
Set up federation, and create a nickname for the RDS for Db2 database table on the self-managed Db2 instance.
-
Connect to your local database. In the following example, replace
source_database_namewith the name of the database on your self-managed Db2 instance.db2 connect tosource_database_name -
Create a wrapper to access Db2 data sources.
db2 create wrapper drda -
Define a data source on a federated database. In the following example, replace
adminandadmin_passwordwith your credentials for your self-managed Db2 instance. Replacerds_database_namewith the name of the database on your RDS for Db2 DB instance.db2 "create server rdsdb2 type DB2/LUW version '11.5.9.0' \ wrapper drda authorization "admin" password "admin_password" \ options( dbname 'rds_database_name', node 'remnode')" -
Map the users on the two databases. In the following example, replace
master_usernameandmaster_passwordwith your credentials for your RDS for Db2 DB instance.db2 "create user mapping for user server rdsdb2 \ options (REMOTE_AUTHID 'master_username', REMOTE_PASSWORD 'master_password')" -
Verify the connection to the RDS for Db2 server.
db2 set passthru rdsdb2 -
Create a nickname for the table in the remote RDS for Db2 database. In the following example, replace
NICKNAMEandTABLE_NAMEwith a nickname for the table and the name of the table.db2 create nickname REMOTE.NICKNAMEfor RDSDB2.TABLE_NAME.NICKNAME
-
-
Insert data into the table in the remote RDS for Db2 database. Use the nickname in a
selectstatement on the local table in the self-managed Db2 instance. In the following example, replaceNICKNAMEandTABLE_NAMEwith a nickname for the table and the name of the table.db2 "INSERT into REMOTE.NICKNAMEselect * from RDS2DB2.TABLE_NAME.NICKNAME"