By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

sql query for displaying only column names

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.