This article will answer following questions.
- How to move DB2 database from one operating system to other?
- How to create database for which the structure creation file (db2look) is not there?
- How to move only few tables from one database to other?
- What is way for O/S independent backup in db2?
- How to change path of tablespaces while restore? (not using redirect restore)
This utility of DB2 create operating system independent backup. It will create one data file for each table you have in your database. This is easiest method for remote backup and restore of database for small size database. It is very useful for the organizations which are working on development area. The situation over here is you need to backup one database on one location and needs to deploy on other location. Suppose you have development going on using a server which is dedicated for development team. QA team needs database which is running at client end, so as they can test issues as per client environment. Here the operating system needed is not available, so this is very useful tool provided by DB2.
We will look into one by one how to move database using this utility to external files. When this tool is used with EXPORT/IMPORT/LOAD mode, facilities the data movement in PCI/IXF files. There are many options for schema, copy schema and other. This article will touch some of them.
This article will provide commands which need to be executed for moving database with some of screen shot in this. Let’s start the activity with exporting database into ixf files for each table.
All these exercises will done using sample database, which is created after installation, using command
bash-3.00$ db2sampl
Creating database “SAMPLE”…
We will export this database to external files, using following commands.
bash-3.00$ db2move sample export
We can see following output which is written on screen.
Action: EXPORT
Start time: Wed Feb 8 13:07:54 2012
Connecting to database SAMPLE … successful! Server : DB2 Common Server V9.7.5
EXPORT: 18 rows from table “DBAV97 “.”ACT”
EXPORT: 0 rows from table “DBAV97 “.”CATALOG”
EXPORT: 5 rows from table “DBAV97 “.”CL_SCHED”
EXPORT: 6 rows from table “DBAV97 “.”CUSTOMER”
EXPORT: 14 rows from table “DBAV97 “.”DEPARTMENT”
EXPORT: 42 rows from table “DBAV97 “.”EMPLOYEE”
EXPORT: 10000 rows from table “DBAV97 “.”EMPMDC”
~~~~~~~
EXPORT: 35 rows from table “DBAV97 “.”STAFFG”
EXPORT: 2 rows from table “DBAV97 “.”SUPPLIERS”
Disconnecting from database … successful!
End time: Wed Feb 8 13:08:00 2012
Where last few lines you will come to know the export command have successfully exported all the needed tables to external files. If you want to create new database on same server or identical server you can use following command.
We will check what kind of files which got exported using this command.
-rw-r–r– 1 dbav97 db2iadm 1585 Feb 08 13:08 EXPORT.out
-rw-r–r– 1 dbav97 db2iadm 946 Feb 08 13:08 db2move.lst
-rw-r–r– 1 dbav97 db2iadm 7208 Feb 08 13:07 tab1.ixf
-rw-r–r– 1 dbav97 db2iadm 142 Feb 08 13:07 tab1.msg
Export.out file contains detail list of tables which got exported with the number of rows it has exported from this table.
EXPORT: 18 rows from table “DBAV97 “.”ACT”
EXPORT: 0 rows from table “DBAV97 “.”CATALOG”
EXPORT: 5 rows from table “DBAV97 “.”CL_SCHED”
EXPORT: 6 rows from table “DBAV97 “.”CUSTOMER”
EXPORT: 14 rows from table “DBAV97 “.”DEPARTMENT”
The db2move.lst file has detail of files which are created with relation of table name.
!”DBAV97 “.”ACT”!tab1.ixf!tab1.msg!
!”DBAV97 “.”CATALOG”!tab2.ixf!tab2.msg!
!”DBAV97 “.”CL_SCHED”!tab3.ixf!tab3.msg!
!”DBAV97 “.”CUSTOMER”!tab4.ixf!tab4.msg!
!”DBAV97 “.”DEPARTMENT”!tab5.ixf!tab5.msg!
The file which has created with .ixf file, is binary file. This contains the table structure and table data. These are the files where data has been exported. You must have seen these kind of files getting generated with db2 export command as well. Export support other formats as well like .del, but in db2move only PCI/IXF format are supported. The last file which is generally created is .MSG file, this contains information about the messages which are generated while export of particular table. It creates .XML file as well, which dumps the XML data for particular table.
Data exporting to external files is done over here.
If new database which needs to be created from this dump is on same or identical server, you can use import method. Create database test with create database command.
db2move test import
* IMPORT: table “DBAV97 “.”STAFFG”
-Rows read: 35
-Inserted: 35
-Rejected: 0
-Committed: 35
IMPORT: table “DBAV97 “.”EMPPROJACT”
-Rows read: 73
-Inserted: 73
-Rejected: 0
-Committed: 73
Sounds so simple aren’t it? You are done with your work.
How to move to other server? Other server might not have same partition (unix partitions) or drive (windows drive). You need to change the container path. Here after the export is finished. Database structure needs to be captured in a file. This can be done using db2look utility. Following is command to execute db2look and get all structure of database. The output file generated using this looks like as follows.
bash-3.00$ db2look -d sample -e -l -xd -o db2look.ddl
— No userid was specified, db2look tries to use Environment variable USER
— USER is: DBAV97
— Creating DDL for table(s)
— Output is sent to file: db2look.ddl
— Binding package automatically …
— Bind is successful
— Binding package automatically …
— Bind is successful
— This CLP file was created using DB2LOOK Version “9.7″
— Timestamp: Wed Feb 8 15:59:45 IST 2012
— Database Name: SAMPLE
— Database Manager Version: DB2/AIX64 Version 9.7.5
— Database Codepage: 1208
— Database Collating Sequence is: IDENTITY
CONNECT TO SAMPLE;
————————————
— DDL Statements for TABLESPACES –
————————————
CREATE LARGE TABLESPACE “IBMDB2SAMPLEREL” IN DATABASE PARTITION GROUP IBMDEFAULT
GROUP
PAGESIZE 8192 MANAGED BY AUTOMATIC STORAGE
AUTORESIZE YES
INITIALSIZE 32 M
MAXSIZE NONE
EXTENTSIZE 32
PREFETCHSIZE AUTOMATIC
—————————————-
If you want to change any container, you need to edit the db2look.ddl file. Make appropriate changes in this and execute it. You need to change the database name in db2look file. It should be the new database name.
Here it comes first time on
~~~~~
— Database Collating Sequence is: IDENTITY
CONNECT TO SAMPLE;
————————————
— DDL Statements for TABLESPACES –
————————————
~~~~~
It needs to connect before buffuerpool creation as well.
This db2look execution will create a database structure. It is a database skeleton.
CREATE TABLE “DBAV97 “.”CL_SCHED” ( “CLASS_CODE” CHAR(7) , “DAY” SMALLINT , “S
TARTING” TIME , “ENDING” TIME ) IN “USERSPACE1″
DB20000I The SQL command completed successfully.
CREATE TABLE “DBAV97 “.”DEPARTMENT” ( “DEPTNO” CHAR(3) NOT NULL , “DEPTNAME” V
ARCHAR(36) NOT NULL , “MGRNO” CHAR(6) , “ADMRDEPT” CHAR(3) NOT NULL , “LOCATION”
CHAR(16) ) IN “USERSPACE1″
DB20000I The SQL command completed successfully.
After this we will load data into this database. Using following command. DB2move with load works very fast.
* LOAD: table “DBAV97 “.”SALES”
-Rows read: 41
-Loaded: 41
-Rejected: 0
-Deleted: 0
-Committed: 41
* LOAD: table “DBAV97 “.”STAFF”
-Rows read: 35
-Loaded: 35
-Rejected: 0
-Deleted: 0
-Committed: 35
If you want to load only certain table, just remove other table name from db2move.lst file and execute simple db2move load command. It will load only tables which are included in .lst file.
Since backup can be taken from one operation system to other, so this is called as os independent backup. Very easy tool to migrate database to other server.
Database support, Database services, Oracle ADF, Mobile Application, Java Application

blogwalking for the day!!!!!!!! cools n nice blogs””””thanks,,,,,,,,,
Thank you
thanks for share!
Thank you!!!
beautiful blog with nice informational content. this is a really interesting and informative post. good job! keep it up, hope to read your other updates. thanks for this nice sharing.
Thank you, planning to post some more things, stay tuned.
i was looking for such easy task from a long time it will help me in increasing my knowledge. thanks a lot.
Thanks a lot, you made my day.
can you explain more about your post? actually, i cannot understand it fully.
Can you be specific, what part of it you don’t get it. Still I am planning to have some more blog on same topic.
i’m glad i have seen this website. and i just want to thank you for taking time to write for us.
Thank you for visiting. Stay tuned, you will see some more things on this blog
this website is the finest world wide web site.
thanks a ton
great site.
If time is money you’ve made me a welahtier woman.
i always agree and interested about every topics in this blog. really inspiring.
thank you Dalva
great. congratulations.
Thank you Denisia
i’ve been looking for this information on other websites, but your articles are awesome and better than the others.
Thank you again Daniele
The purchases I make are entirely based on these arietcls.
i like this subject and it will help me a lot with my homework. thanks for helping.
More to come, stay tuned.
i would like to tell you that your blog is more and more interesting each day.
It will get more interesting in coming days. Stay tuned.
It’s a joy to find soeomne who can think like that
Good site. Congrats … keep it up…!
Please visit and add your comments …!
Sure … thanks for visiting.
If you want to get read, this is how you shuold write.
thank you for your advice !
You are welcome
very interesting website indeed.
Thank you Celma, thank you for visiting
cool, i love it.
thank you very much
everything is very open and very clear explanation of issues. it contains truly information. your website is very useful. thanks for sharing. looking forward to more!
Stay tuned, more to come …. thanks for visiting
your website is the most informative. i loved your website a lot. thank you.
there are many of the articles over internet but this one seems to be taking most of the time. i loved reading it
Thank you for visiting …
keep up buddy, you people are doing a great job.
The content on this publish is really a single of the top material that I’ve ever occur across. I love your article, I’ll appear back to verify for new posts.
Soon you will see some more post on this blog
i like the design and presentation of the site.
Thanks a lot, it take good time to select this.
A better magazine theme will make the blog looks nicer:)
thank you
This really is a really good study I believe, Must admit that you will be among the best bloggers We ever saw.Thank you for writing this educational post.
Stay tuned you will see few more are going to be here on blog
Your article was ecxelelnt and erudite.
thank you!!!
that’s very nice article man. i like reading it.
Stay tuned you will see more interesting things on this blog.
this website is the finest world wide web site.
Wow … thanks
what you provide is very good, i like it so much, thank you, the article you wrote is perfect!
Great … thank you for visiting
my friend, i am now a big fan of yours and your blog’s follower, thanks for the help.
Do have the RSS feed … so as it will be easy for you to follow.
i think to write in blogs, you have to be very focused on what is the main subject and the rest comes casually.
i do check this site often as it is very good and informative and will look out for an answer!
i never knew we could search for something like that it’s interesting and something i might look into when i find some free time!
I certainly learned about much of this, but with that in mind, I still considered it had been beneficial. Excellent task!
I’m very inspired along with your site because smartly using the structure to your weblog. Is that this a compensated theme or have you colorize it for you yourself? Either way keep up the superb high quality composing, it is uncommon to see a great blog such as this one nowadays.
i can always trust your information to make my homework or just to learn something more.
its great stuff. thanks for sharing…waiting for your next update.
Sorry for the huge review, but I’m really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it’s the right choice for you.
Thank you for your extremely great information and feedback from you.
Wonderful info, far better still to find out your weblog that has a fantastic layout. Nicely done
I like you blog
I’m generally to blogging and i truly appreciate your content regularly. The content has truly peaks my interest. My goal is to bookmark your internet weblog and maintain checking for 1st time information.
Excellent post, you’ve pointed out some excellent points, I besides believe this is a extremely fantastic site.
An incredibly interesting examine, I may not agree completely, but you do make some extremely legitimate factors.
Thank you for the great writeup. through the way, how could we communicate?
I think this is among the most vital info for me. And i’m glad reading your post. But wanna remark on couple of general points, The internet site style is perfect, the articles is really fantastic : D. Excellent job, cheers
Discovered your weblog and decided to have a study on it, not what I generally do, but this weblog is great. Awesome to see a site that’s not spammed, and actually makes some sense. Anyway, fantastic write up.
Write far more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You surely know what youre talking about, why throw away your intelligence on just posting videos to your weblog when you can be giving us something informative to read?
Hey there, You have done a fantastic job. I will surely digg it and personally recommend to my friends. I’m confident they will likely be benefited from this site.
You actually make it seem so easy along with your presentation but I uncover this matter to be really something that I believe I would never realize. It seems too complex and incredibly broad for me. I’m seeking forward for your next post, I will try to get the hang of it!
I got what you mean , regards for posting .Woh I am pleased to locate this site by means of google.
great website, great posts. i will also encourage my friends to read your posts.
This article has inspired me to start focusing on my own blog
Value this pleasant article and in addition you find article additional to publish exceptional many thanks!
I adored your wonderful site. topnotch stuff. I hope you write others. I will continue subscribing
I’d must check with you here. Which isn’t something I often do! I enjoy studying a submit that will make people think. Additionally, thanks for allowing me to comment!
Hey, I just stopped in to visit your blog and thought I’d say I enjoyed myself.
nice site. good job.
This could be a very good study in my experience, Need to acknowledge that you actually are one of the finest writers I actually noticed.Appreciate writing this useful post.