473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 83541
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe Gazda | last post by:
I'm a relative newbie to PHP, but have been able to put together some PHP code to generate a CSV/XLS file from a Query result. Now, I would like to include custom column names instead of the MySQL...
1
by: noor | last post by:
Hi I have been working since 2 days to device a method to export sql table into csv format. I have tried using bcp with format option to keep the column names but I'm unable to transfer the file...
2
by: Piotr Kurpiel | last post by:
Hello, I am using MS Access 2003 with VBScript. I have quite strange column names which are: 1,2,3,4,etc... Data Types of the columns are Yes/No and formats True/False. The first thing I want to...
3
by: Harry Whitehouse | last post by:
How might one go about this. I know how to select data records, but suppose I wanted to fill a datagrid with the column names in a specified table? How would I start? TIA Harry
7
by: | last post by:
Need help finding simple way to retrieve a fields (or columns) collection from a Dataset without filling it first.
2
by: craigkenisston | last post by:
Im trying to make an application using all the out of the box stuff for data displaying. Using (or trying to) use a BLL and DLL. Now, in my database, the tables and columns have names like these: ...
1
by: christianlott1 | last post by:
I want to provide users with an interface to create a custom merge (all in Access, not Word). User will put in a set of brackets ("<>") in a memo field and when they click the merge button it will...
1
by: bugs2bugs | last post by:
Hello, We're using SQL Server 2000 and Query Manager (not Visual Studio). When your query results are returned, the column names are displayed at the top, but this information is NOT available for...
1
by: ncsthbell | last post by:
Once again... I am supporting another Access database that I did not build. The previous 'owner' of this built the tables with spaces in the table names as well as the column names. I am having a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.