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 > Getting table structure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-23-11, 12:04
merik merik is offline
Registered User
 
Join Date: Apr 2011
Posts: 32
Getting table structure

I come from a MySQL background; in MySQL you could easily see the structure of a table by running "EXPLAIN tablename" which would list the columns, their data type, whether they are indexed, etc. How do you do the same thing in DB2? Also where is a good place to search for these basic stuff (searching DB2 documentation is usually helpless)?
Reply With Quote
  #2 (permalink)  
Old 05-23-11, 13:12
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Check the DESCRIBE command in the helpless manual.
Reply With Quote
  #3 (permalink)  
Old 05-23-11, 13:14
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
You can use these commands:

db2 describe table table-name (show detail)
db2 describe indexes for table table-name (show detail)

To get the entire schema for a table:

db2look -d db-name -t table-name -e -a

The InfoCenter is OK if you know what you are looking for, but the PDF versions of the manuals are also good to browse and search (using PDF search). The most important manuals are these:
  • Command Reference
  • SQL Reference Vol 1 - Select Statement, functions, DB2 catalog
  • SQL Reference Vol 2 - All other SQL
  • Message Reference Vol 2 - SQL Error Messages
https://www-304.ibm.com/support/docview.wss?rs=71&uid=swg27009474

PDF Links are at the bottom of the page.
__________________
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
  #4 (permalink)  
Old 05-23-11, 15:43
merik merik is offline
Registered User
 
Join Date: Apr 2011
Posts: 32
Quote:
Originally Posted by n_i View Post
Check the DESCRIBE command in the helpless manual.
The manual is helpless, because I couldn't find my way to "DESCRIBE" using it. A hint from you made it very useful of course. However, I find documentation of some other DBMS more straightforward for non-professional users like me.
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