Avatar of Prardhan N
Prardhan N
Flag for India asked on

Does db2 move utility work for different environments if they are on different servers

Hi All

Does db2 move utility work for different environments if they are on different servers (with different IPs)?

    db2move sample COPY -sn BAR -co target_db  target schema_map
      "((BAR,FOO))" -u userid -p password  

I need to do copy a schema.
need DB cataloging?

Connecting to database SOURCEDB... successful!  Server : DB2 Common Server V10.5.7

**ERROR - Failed to connect to target database : TARGETDB


db2move failed with -1 (debuginfo:19)

can you pls help
Databases* dbaDB2

Avatar of undefined
Last Comment
Prardhan N

8/22/2022 - Mon
Kent Olsen

Hi Sridhar,

The DB2 move utility can't be used to move a database to another server.  

The traditional way to accomplish that move is with a full backup on the source server and a restore on the target server.


Kent
Prardhan N

ASKER
I just need to copy the schema with data , not the DB.

but between different DBs which are in different machines.
Kent Olsen

BACKUP DATABASE myDB TO path/filename

The BACKUP DATABASE statement will back up any schema/database on the server.  In this case the terms "schema" and "database" are nearly synonymous.  That can be confusing as the terms "Database" and "instance" are often interchanged, too.  Making matters worse is that all vendors don't subscribe to the same definitions.  :(
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Prardhan N

ASKER
For some reason, i want to use db2move utility, any inputs on this.
Kent Olsen

Unless the functionality was recently added (and I see no evidence that it was) db2move doesn't support it.  The utility uses direct I/O (skipping some of the DBMS overhead) to accomplish things at a lower level than the database.
Tomas Helgi Johannsson

Hi!

To move a schema with tables and data using db2move then you could use it like this (always works for me :) )
Export
db2move DBSOURCE export -aw -l lobs -sn schema1

Open in new window

Import
db2move DBTARGET import -io replace_create -l lobs

Open in new window


Or similar to your command.
 db2move dbsrc COPY -sn schema1 -co TARGET_DB dbtgt USER myuser1 USING mypass1
        SCHEMA_MAP ((schema1,newschema1)) TABLESPACE_MAP ((ts1,ts2), SYS_ANY))

Open in new window


Note that this command requires : The TARGET_DB cannot be the same as the source database and must be a local database.
So if the the target database is a remote database to the source then use the export/import method copying the exported data between hosts.

https://www.ibm.com/support/knowledgecenter/SSEPGG_10.1.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0002079.html

Regards,
     Tomas Helgi
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Prardhan N

ASKER
Yes, target Db is on Remote Host.  Does Db2move does not work for remote machine directly ?

Shall i use db2move export
then ftp the files
then shall i Import or load the data ?

is that you are suggesting?
Tomas Helgi Johannsson

Hi!

Yes, use the export/import method in your case.

Regards,
    Tomas Helgi
Prardhan N

ASKER
have many tables in the schema, do i need to export and ftp hundred of  files and load or import it.

Any simple way?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Prardhan N

ASKER
Hi ,
do we have any Db2 utility does the operation(Schema copy with DDL and Data) over network for a remote target DB?
Tomas Helgi Johannsson

Hi!

No, I'm afraid not.
The export command I gave you exports all tables in the provided schema1 in one go.
And the import of the entire schema1 is also done in one single command.
All you need to do is to be in a directory ( on a disk) big enough to hold the exported data/files.
If you are on *nix then you can use scp commands to copy the entire directory to the remote host in one go.
So actually,  it's only 3 commands you need to execute.

Regards,
     Tomas Helgi
Prardhan N

ASKER
Hi

what is the use of  "lobs" paramter? Is it to include lob data type data ?

I have lob data as well.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Prardhan N

ASKER
if i want a new schema name in my remote DB

How to do that ?

I think 3rd command will only work for local Data Base.
Tomas Helgi Johannsson

Hi!

You can follow this in the guide to do the schema change inside the same database.
Basically open a connetion to the database as the instance owner or SYSDBA user
and issue the ADMIN_COPY_SCHEMA command
with the required schemanames

Example (see the above link for more info especially the copymode - COPY/COPYNO option)
CALL SYSPROC.ADMIN_COPY_SCHEMA('SOURCE_SCHEMA', 'TARGET_SCHEMA', 
   'COPY', NULL, 'SOURCETS1 , SOURCETS2', 'TARGETTS1, TARGETTS2, 
   SYS_ANY', 'ERRORSCHEMA', 'ERRORNAME') ;

Open in new window


Regards,
     Tomas Helgi
Prardhan N

ASKER
Thanks for info. As per your inputs and my reading schema name change is not possible directly.

The only way is to create a new schema(with required name) through ADMIN_COPY_SCHEMA utility and drop the old one.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Tomas Helgi Johannsson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Prardhan N

ASKER
Thanks for your valuable inputs.

Appreciating your knowledge sharing.