469,342 Members | 6,455 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

sql query for displaying only column names

I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

May 24 '07 #1
4 82728
On May 24, 8:50 am, mailsu...@gmail.com wrote:
I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?
SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAILS'

May 24 '07 #2
On May 24, 2:19 pm, situ <SRIDHAR...@REDIFFMAIL.COMwrote:
On May 24, 8:50 am, mailsu...@gmail.com wrote:
I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAILS'
Thanks !

May 24 '07 #3
ma*******@gmail.com wrote:
On May 24, 2:19 pm, situ <SRIDHAR...@REDIFFMAIL.COMwrote:
>On May 24, 8:50 am, mailsu...@gmail.com wrote:
I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAILS'
In addition to situs answer, I you are running your query from a host
language such as java, a common trick is to select from the table with a
predicate that is always false, and then grab the metadata from the
resultset. I.e.

select * from DETAILS where 1=0

I'm not saying that this is better, only that it is another possability
/Lennart

May 24 '07 #4
Ian
Lennart wrote:
ma*******@gmail.com wrote:
>On May 24, 2:19 pm, situ <SRIDHAR...@REDIFFMAIL.COMwrote:
>>On May 24, 8:50 am, mailsu...@gmail.com wrote:

I would like to know the SQL statement for displaying only the column
names of a particular table. For eg. if I have a table by the name
DETAILS and it has three columns FIRST_NAME, LAST_NAME and
DT_OF_BIRTH, using what SQL statement can I display only the column
names and not their content ?

SELECT TABNAME,COLNAME from SYSCAT.COLUMNS where TABNAME='DETAILS'

In addition to situs answer, I you are running your query from a host
language such as java, a common trick is to select from the table with a
predicate that is always false, and then grab the metadata from the
resultset. I.e.

select * from DETAILS where 1=0

I'm not saying that this is better, only that it is another possability
Or how about 'DESCRIBE TABLE DETAILS'

May 24 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Joe Gazda | last post: by
3 posts views Thread by Harry Whitehouse | last post: by
2 posts views Thread by craigkenisston | last post: by
1 post views Thread by christianlott1 | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.