db2 Migrate
db2 Migrate
In this case we will create the DB2INST1 user – the same schema as the DB2 database.
Tablespace created.
User created.
Grant succeeded.
Grant succeeded.
Create a connection DB2MIG connecting to the target Oracle database
Cop y the files db2jcc.jar and db2jcc_license_cu.jar from the server hosting the DB2 instance to the client PC from where we will be running
Oracle SQL Developer.
These files will be located in the java sub-directory of the DB2 software home directory.
Go to Tools > Preferences > Database > Third Party JDBC Drivers and click on the Add Entry button.
Provide the location of the db2jcc.jar file which you have copied to your client PC. Do the same for the other file db2jcc_license_cu.jar as well.
Create a new connection to the DB2 source database. We will need the hostname, database name, database username, password and the JDBC port
number details to create the DB2 conection.
db2c_db2inst1 50001/tcp
We can now connect to the DB2 source database and query some tables to confirm that the connection is working fine.
For the migration, we need to first create a Repository in the Oracle database environment.
TABLE_NAME
------------------------------
MD_TABLESPACES
MD_USER_PRIVILEGES
MD_REPOVERSIONS
MD_USERS
MD_GROUP_MEMBERS
MD_CATALOGS
MD_SEQUENCES
MD_COLUMNS
MD_CONNECTIONS
MD_PROJECTS
MD_MIGR_PARAMETER
MD_INDEX_DETAILS
MD_OTHER_OBJECTS
MD_CONSTRAINTS
MD_USER_DEFINED_DATA_TYPES
MIGR_DATATYPE_TRANSFORM_MAP
MD_GROUPS
MD_ADDITIONAL_PROPERTIES
MIGRLOG
MD_TABLES
MD_PACKAGES
MD_GROUP_PRIVILEGES
MD_VIEWS
MD_INDEXES
MIGR_DATATYPE_TRANSFORM_RULE
MD_SCHEMAS
MD_REGISTRY
MD_DERIVATIVES
MD_SYNONYMS
MD_TRIGGERS
MD_MIGR_DEPENDENCY
MD_PRIVILEGES
MIGR_GENERATION_ORDER
MD_MIGR_WEAKDEP
MD_CONSTRAINT_DETAILS
MD_STORED_PROGRAMS
MIGRATION_RESERVED_WORDS
37 rows selected.
Let us now test the migration of the ACCBANK table from the DB2 database to the Oracle target database.
Note the structure of the table in the DB2 source
db2 => DESCRIBE SELECT * FROM ACCBANK
Column Information
Number of columns: 20
-----------
7660
1 record(s) selected.
Expand the DB2INST1 schema under the DB2_SOURCE connection in the SQL Developer. Expand tables and right click on the table ACCBANK. Click on the
menu option Quick Migrate
This will bring us to the Quick Migration screen. Ensure that the Target Connection in Step 2 and the Repository chosen in Step 3 are the right database
connections.
Click on the Verify button and then we will select the option “Migrate Everything” from the Migration Type List of Values
For example, the column RECORDID which was BIGINT in DB2 has now become a NUMBER column with precision 19.
SQL> DESC ACCBANK
We see that the row count is the same as the DB2 database and also the indexes on the table have been created as well.
SQL> SELECT COUNT(*) FROM ACCBANK;
COUNT(*)
----------
7660
INDEX_NAME
------------------------------
CC1248759703146
Let us now see another method of doing a table migration from DB2 to Oracle using SQL Developer. In essence these are the same steps which Quick
Migrate option goes through automatically, but doing in manually will give us a better overview of the entire process.
Right click on the table name and select the menu option “Capture Table”
Once the table has been captured, we will see in the left hand window pane, Captured Models. If we expand that it will show us the table which has been
captured.
In the Captured Models window pane, expand the Tables and right click on the Table name which we have captured and select the option “Convert to
Oracle Model”
We will now see another window pane “Converted Models” which will have all the models which have been converted to Oracle format.
Highlight the particular Converted Model and right click – select the Generate option
It will generate the necessary DDL scripts – we can exclude the option to create the user DB2INST1 as we have already created the user in the Oracle
database.
Click on Run Script icon in the SQL Worksheet tab
Finally, we have to move the data to the table which has been created in the Oracle database.
Right Click on the particular Converted Model and select the option Move Data