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 > CREATE TABLE DDL from system catalog

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-20-08, 17:12
db2rocks db2rocks is offline
Registered User
 
Join Date: Jan 2008
Posts: 45
CREATE TABLE DDL from system catalog

Hi friends,

Is there a way of getting a table DDL from syscat.tables??I know we can get storedprocedure,view,function,trigger DDL from syscat views.I am wondering if there is a way of getting DDL of a table or index from syscat


thanks
Reply With Quote
  #2 (permalink)  
Old 02-20-08, 18:01
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Have a look at the "db2look" utility.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 02-20-08, 18:10
db2rocks db2rocks is offline
Registered User
 
Join Date: Jan 2008
Posts: 45
Yeah db2look can be used to get DDL..I was wondering if we can get the DDL from syscat.tables or systat.tables views for tables and indexes.


Thanks
Reply With Quote
  #4 (permalink)  
Old 02-20-08, 18:18
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
No, the text to create tables and indexes is not stored in the DB2 catalog views. I believe it is there for triggers, views, and routines because DB2 may have to re-process those objects at various points - but that's not the case for tables and indexes.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 02-20-08, 18:20
db2rocks db2rocks is offline
Registered User
 
Join Date: Jan 2008
Posts: 45
Thanks for the information Stolze.I was wondering how the thirdy party vendors like quest get that DDL for each table and each index separately..May be they use db2look?? Any ideas
Reply With Quote
  #6 (permalink)  
Old 02-20-08, 18:42
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
All the information is in the DB2 catalog. You'd just have to piece it together - the same way db2look does it. I would assume that other vendors go against the catalog as well.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 02-20-08, 18:49
db2rocks db2rocks is offline
Registered User
 
Join Date: Jan 2008
Posts: 45
Thanks for the information Stolze
Reply With Quote
  #8 (permalink)  
Old 02-20-08, 18:55
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
The DB2 Control Center will show you the table DDL for an individual table. If you hit the "Show SQL" button that shows how the CC got the DDL, you will see it uses db2look command using the opiton to extract DDL for the one table.

If you want to see the columns in a table (not necessarily the DDL), you can issue this command:

db2 describe table <table-name> show detail (show detail is optional)

db2 describe indexes for table <table-name> show detail (show detail is optional)
__________________
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