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 > How To Find Dependency

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-27-11, 18:03
captainlaw captainlaw is offline
Registered User
 
Join Date: May 2011
Posts: 11
How To Find Dependency

Hello,
I want to drop table Student, but would like to find views and sprocs using table Student. Does anyone have an example of using Student to find all dependent objects?

For view, is there a function that provides the actual schema, suchas sp_helptext in SQL?

I notice some people use SYSCAT.ROUTINEDEP. But how do I query that function to return the objects related to Table Student?

What about for VIEWS that reference table Student? How do I query that?

Thanks for your help!
Reply With Quote
  #2 (permalink)  
Old 05-27-11, 18:17
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
SYSCAT.ROUTINEDEP is a catalog view, not a function. There are others like that, e.g. TABDEP (for tables and views), PACKAGEDEP (for SQL packages) etc. You use standard SQL to query them.

More information here: System catalog views - IBM DB2 9.7 for Linux, UNIX, and Windows
Reply With Quote
  #3 (permalink)  
Old 05-27-11, 18:44
captainlaw captainlaw is offline
Registered User
 
Join Date: May 2011
Posts: 11
I'm having issue with the syntax when using these catalog.
What's the syntax for all dependent objects for table [Student] using TABDEP?

Also, any function such as sp_helptext in SQL?
Reply With Quote
  #4 (permalink)  
Old 05-27-11, 19:45
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Try db2look, you can use -t option to get DDL just for the table and its dependent objects
Reply With Quote
  #5 (permalink)  
Old 05-27-11, 20:18
captainlaw captainlaw is offline
Registered User
 
Join Date: May 2011
Posts: 11
I've discovered syntax is quite complex compared with SQL.

I'm getting syntax error - An unexpected token "db2look -t" was found following "BEGIN-OF-STATEMENT""

db2look -t mktg.student

Goal - trying to figure out exact syntax to find all dependent objects related to student before I delete the object.
Reply With Quote
  #6 (permalink)  
Old 05-27-11, 20:30
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Example:
db2look -d <db name> -e -t <table name>

You can redirect the output to a file
Reply With Quote
  #7 (permalink)  
Old 05-27-11, 23:24
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
db2look is not an SQL statement, it is a DB2 system command. See the DB2 Command Reference manual for more details.

Here is the PDF manual for DB2 9.7:
http://public.dhe.ibm.com/ps/product...-db2n0e972.pdf
__________________
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
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