View previous topic :: View next topic
|
Author |
Message |
trilokdewangan
New User
Joined: 19 Jun 2008 Posts: 39 Location: USA
|
|
|
|
Hello,
I have a complex DB2 database where the RI relation is complex (parent, child relationship). I am trying to create a load process for whole database, but I don't have sequence (order) to load the tables. Can anyone suggest on this?
Thank you. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Depending on specifics, you could load all of the tables that have no RI constraints. Then load the tables that require these other tables to be loaded.
Again, depending on specifics, you might consider taking off the RI until after the tables are loaded. This depends on 100% of the data being valid as relates to the RI rules or there will be problems.
Possibly, i have misunderstood the question. . . |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
there are topics in this forum that discuss determining the RI relationships between tables.
a search should provide that sql.
or you can start with E.1 Retrieving catalog information about ...
here are 4 sysibm.tables that will help:
SYSIBM.TABLE_CONSTRAINTS
SYSIBM.CHECK_CONSTRAINTS
SYSIBM.REFERENTIAL_CONSTRAINTS
SYSIBM.REF_CONSTRAINTS |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Besides,
some DBA in your shop has this documented. try checking with him/her. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
Back to top |
|
|
satyender
New User
Joined: 05 Jan 2008 Posts: 50 Location: Olympia, WA, USA
|
|
|
|
trilokdewangan,
Try the below query:
SELECT NAME, '' AS PARENT_NAME FROM SYSIBM.SYSTABLES A WHERE CREATOR = 'USER_ID' AND NAME NOT IN
(SELECT TBNAME FROM SYSIBM.SYSRELS WHERE CREATOR = 'USER_ID' )
UNION
SELECT A.TBNAME AS NAME , A.REFTBNAME AS PARENT_NAME FROM SYSIBM.SYSRELS A WHERE CREATOR = 'USER_ID' |
|
Back to top |
|
|
|