gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · web viewcreate the...

39
Create the user in the Oracle database. In this case we will create the DB2INST1 user – the same schema as the DB2 database. SQL> create tablespace DB2_DATA datafile '+DATA2' size 20G; Tablespace created. SQL> create user DB2INST1 identified by DB2INST1 2 default tablespace DB2_DATA 3 temporary tablespace temp 4 quota unlimited on DB2_DATA; User created. SQL> grant dba to DB2INST1; Grant succeeded. SQL> GRANT RESOURCE TO DB2INST1 WITH ADMIN OPTION; Grant succeeded.

Upload: others

Post on 18-Sep-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Create the user in the Oracle database.

In this case we will create the DB2INST1 user – the same schema as the DB2 database.

SQL> create tablespace DB2_DATA datafile '+DATA2' size 20G;

Tablespace created.

SQL> create user DB2INST1 identified by DB2INST1

2 default tablespace DB2_DATA

3 temporary tablespace temp

4 quota unlimited on DB2_DATA;

User created.

SQL> grant dba to DB2INST1;

Grant succeeded.

SQL> GRANT RESOURCE TO DB2INST1 WITH ADMIN OPTION;

Grant succeeded.

Create a connection DB2MIG connecting to the target Oracle database

Page 2: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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.

Page 3: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

These files will be located in the java sub-directory of the DB2 software home directory.

For example - /opt/ibm/db2/V9.7/java

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.

Page 4: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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.

In our case it is 50001.

We can find the port number by issuing these DB2 CLP commands

[db2inst1@blade20 ~]$ db2 get dbm cfg |grep SVCE

TCP/IP Service name (SVCENAME) = db2c_db2inst1

SSL service name (SSL_SVCENAME) =

[db2inst1@blade20 ~]$ cat /etc/services |grep db2c_db2inst1

db2c_db2inst1 50001/tcp

Page 5: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 6: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

We can now connect to the DB2 source database and query some tables to confirm that the connection is working fine.

Page 7: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 8: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

For the migration, we need to first create a Repository in the Oracle database environment.

Click on Migration > Repository Management > Create Repository

Page 9: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Select the database in which we will create the Repository and click on the Create button

Page 10: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 11: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

We will see that it will create a number of tables with the prefix ‘MD’ in the schema used for the repository creation.

SQL> select table_name from user_tables;

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

Page 12: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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.

Page 13: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Note the structure of the table in the DB2 source

db2 => DESCRIBE SELECT * FROM ACCBANK

Column Information

Number of columns: 20

SQL type Type length Column name Name length

-------------------- ----------- ------------------------------ -----------

492 BIGINT 8 RECORDID 8

500 SMALLINT 2 COMPANY 7

500 SMALLINT 2 SUBCOY 6

500 SMALLINT 2 STATE 5

500 SMALLINT 2 BRANCH 6

452 CHARACTER 1 RECEIPTPF 9

496 INTEGER 4 RECEIPT 7

452 CHARACTER 1 MANRECTPF 9

496 INTEGER 4 MANRECT 7

484 DECIMAL 11, 2 CASHAMT 7

484 DECIMAL 11, 2 CHQAMT 6

484 DECIMAL 11, 2 PREVBNKAMT 10

484 DECIMAL 11, 2 CREDITAMT 9

Page 14: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

452 CHARACTER 40 RCVDFROM 8

484 DECIMAL 6, 0 BANKBSB 7

452 CHARACTER 20 CREDITNO 8

452 CHARACTER 1 CRDSYSTM 8

452 CHARACTER 2 CRDTYPE 7

452 CHARACTER 1 CRDORDER 8

452 CHARACTER 1 BANKDEP 7

Note the number of rows in the source table

db2 => SELECT COUNT(*) FROM ACCBANK

1

-----------

7660

1 record(s) selected.

Page 15: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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

Page 16: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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

Page 17: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

CHANGE MIGRATION TYPE DROP DOWN TO MIGRATE EVERYTHING

Page 18: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Note the stages of the Quick Migration – data is first Captured, then Converted to Oracle format, then DDL scripts are generated, objects Built and finally Data is Moved.

Page 19: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 20: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 21: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Let us now see the ACCBANK table in Oracle. Note the column data type changes which have occurred.

For example, the column RECORDID which was BIGINT in DB2 has now become a NUMBER column with precision 19.

SQL> DESC ACCBANK

Name Null? Type

----------------------------------------- -------- ----------------------------

RECORDID NOT NULL NUMBER(19)

COMPANY NOT NULL NUMBER(5)

SUBCOY NOT NULL NUMBER(5)

STATE NOT NULL NUMBER(5)

BRANCH NOT NULL NUMBER(5)

RECEIPTPF NOT NULL CHAR(1 CHAR)

RECEIPT NOT NULL NUMBER(10)

MANRECTPF NOT NULL CHAR(1 CHAR)

MANRECT NOT NULL NUMBER(10)

CASHAMT NOT NULL NUMBER(38)

CHQAMT NOT NULL NUMBER(38)

PREVBNKAMT NOT NULL NUMBER(38)

CREDITAMT NOT NULL NUMBER(38)

RCVDFROM NOT NULL CHAR(40 CHAR)

BANKBSB NOT NULL NUMBER(38)

CREDITNO NOT NULL CHAR(20 CHAR)

CRDSYSTM NOT NULL CHAR(1 CHAR)

CRDTYPE NOT NULL CHAR(2 CHAR)

Page 22: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

CRDORDER NOT NULL CHAR(1 CHAR)

BANKDEP NOT NULL CHAR(1 CHAR)

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

SQL> SELECT INDEX_NAME FROM USER_INDEXES WHERE TABLE_NAME='ACCBANK';

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.

Page 23: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Right click on the table name and select the menu option “Capture Table”

Page 24: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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.

Page 25: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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”

Page 26: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 27: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

We will now see another window pane “Converted Models” which will have all the models which have been converted to Oracle format.

Page 28: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Highlight the particular Converted Model and right click – select the Generate option

Page 29: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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.

Page 30: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 31: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

Click on Run Script icon in the SQL Worksheet tab

Page 32: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 33: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 34: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the

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

Page 35: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the
Page 36: gavinsoorma.comgavinsoorma.com/wp-content/uploads/2010/10/db2_migrate.docx · Web viewCreate the user in the Oracle database. In this case we will create the DB2INST1 user – the