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 > SQL to get column types of a table?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-10-04, 07:25
danielbrowne danielbrowne is offline
Registered User
 
Join Date: Feb 2004
Posts: 20
SQL to get column types of a table?

Hi,

I have looked through various posts as well as hunted for a DB2 data dictionary but still can' t find the solution in basic SQL. Can someone even point me at
the data dictionary as I couldn't find it on the IBM site.

I can do this in Oracle, Teradata, Sybase and SQL Server but I'm fairly new to DB2.

Thanks in advance.

Cheers,
Daniel.
Reply With Quote
  #2 (permalink)  
Old 09-10-04, 07:38
danielbrowne danielbrowne is offline
Registered User
 
Join Date: Feb 2004
Posts: 20
I think I'm getting close with:

select name, tbname, coltype, length, scale from sysibm.syscolumns where tbname = <mytable>

I also should have said earlier that I'm running DB2 8.1 on Windows 2003 and connecting from solaris.
Reply With Quote
  #3 (permalink)  
Old 09-10-04, 07:47
Romeo Romeo is offline
Registered User
 
Join Date: Feb 2002
Location: Philippines
Posts: 41
how about:

DESCRIBE TABLE <tablename>

is that what you need?
__________________
There are 10 kinds of people,
those who know binary and those who don't.

http://www.linkedin.com/in/rtitong
Reply With Quote
  #4 (permalink)  
Old 09-10-04, 08:03
Romeo Romeo is offline
Registered User
 
Join Date: Feb 2002
Location: Philippines
Posts: 41
Quote:
Originally Posted by danielbrowne
I think I'm getting close with:

select name, tbname, coltype, length, scale from sysibm.syscolumns where tbname = <mytable>

I also should have said earlier that I'm running DB2 8.1 on Windows 2003 and connecting from solaris.
yup... using a select statement, that should be what you
__________________
There are 10 kinds of people,
those who know binary and those who don't.

http://www.linkedin.com/in/rtitong
Reply With Quote
  #5 (permalink)  
Old 09-10-04, 11:59
danielbrowne danielbrowne is offline
Registered User
 
Join Date: Feb 2004
Posts: 20
Thumbs up

Thanks guys. I opted for the "select..." option as I'm using unixODBC's 'isql'.

thanks.
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