If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2Move import issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-05, 11:27
mohd mohd is offline
Registered User
 
Join Date: Jul 2003
Posts: 63
DB2Move import issue

Hi
I am using DB2 V8.1 on solaris.

I want to move schema from one databse to another databse under diff server


Here is what i did.

1. on source system ( to get the struc of all the schema objects)
db2look -d sample -e -z db2inst1 -x -o sch_struc_db2inst1.out -u db2inst1

2. On target ( to create the struct of schema)
db2 -tvf c:\sch_struc_db2inst1.out

3. on source ( to get the tables data )
Db2move sample export -sn db2inst1

4. on target ( to import the table data )
DB2move sample import -io replace

in step 4 it has imported the tables which doesnt have any dependent tables
but for the master table it has not imported the data giving error :

SQL3201N The specified table cannot be replaced because another table is
dependent on it.

what i am missing in step 4?

will appreciate quick response
thx
__________________
Mohd
Reply With Quote
  #2 (permalink)  
Old 02-16-05, 11:42
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
It's rather in step 2 - you would want to create RI constraints after importing data, not before.
Reply With Quote
  #3 (permalink)  
Old 02-16-05, 12:02
mohd mohd is offline
Registered User
 
Join Date: Jul 2003
Posts: 63
Thx for the quick reply,

But i have created the whole schema struc from the output got by db2look comand.

Is there any option in db2look to avoid getting referential constraints while getting whole schema and also to get the constraints alone aftewards to create it.?

Is it the correct way i am following to move schema from one database to another or is there any other way we can do it.

Thx
__________________
Mohd
Reply With Quote
  #4 (permalink)  
Old 02-16-05, 12:09
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The Foreign Keys are all in a seperate section of the db2look output, which you should be able to cut and paste into a separate script and run after the load.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #5 (permalink)  
Old 02-16-05, 12:29
mohd mohd is offline
Registered User
 
Join Date: Jul 2003
Posts: 63
Thx Marcus,

I got it.

Is there any easy way out as i have to do it very frequently.
something like in oravcle we give constraints=no to avoid constraints.

Thx
__________________
Mohd
Reply With Quote
  #6 (permalink)  
Old 02-16-05, 14:38
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
These two queries should produce scripts to drop and re-create foreign keys.
Code:
SELECT 
	'ALTER TABLE schema.' || SUBSTR(TABNAME,1,50), 
	' DROP FOREIGN KEY ' || CONSTNAME || ';' 
FROM 
	SYSCAT.REFERENCES 
where 
	tabschema = 'schema'
;

SELECT 
	'ALTER TABLE schema.' || SUBSTR(TABNAME,1,50), 
	'ADD CONSTRAINT ' || CONSTNAME, 
	'FOREIGN KEY (' || substr(FK_COLNAMES,1,50) || ')', 
	'REFERENCES schema.' || SUBSTR(REFTABNAME,1,17),  
	' ON DELETE ' || 
		case deleterule
		  when 'A' then 'NO ACTION' 
		  when 'C' then 'CASCADE' 
		  when 'N' then 'SET NULL' 
		  when 'R' then 'RESTRICT'
		end, 
	' ON UPDATE ' || 
		case updaterule
		  when 'A' then 'NO ACTION' 
		  when 'R' then 'RESTRICT'
		end 
	FROM 
		SYSCAT.REFERENCES 
	where 
		tabschema = 'schema' 
;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On