Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to select Column names ONLY

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm running DB2 v7.1 for a web-site. I need to know if there's an 'easy' way to select only the column NAMES with no data associated.

Thanks all

rmacholl@aol.com
 
please provide more info about what you are trying to do.
My assumption of what you are trying to do is that say you have table t1 with say 3 columns, col1, col2, and col3 and each column has values stored in them.
How can you just select only the columns without the data values in them, is that your question?
chidi
 
Try using this query

SELECT * FROM TABLE1
WHERE 1 > 2 ;

The condition 1 > 2 will never satisfy and no rows would be fetched. Only the column headings would come.
 
If you want to select just the column names with no data you could try the following :

select * from table where 1=2
 
There is an easy way. The following assumes you are using QMF (embedding in a high-level language will require setting up a CURSOR):

SELECT NAME
FROM SYSIBM.SYSCOLUMNS
WHERE TBNAME = 'name of table or view' Jay
 
Try using describe select * from the tablename. Gives you column names and also the description of each column
Hope this helps
Gk
 
As per JKAPCIA :
SELECT NAME
FROM SYSIBM.SYSCOLUMNS
WHERE TBNAME = 'name of table or view'

I think in DB2 for OS/390 you use NAME.

The query should be changed AS FOLLOWS for UDB;

SELECT COLNAME
FROM COLUMNS
WHERE TABNAME = 'name of table or view'
ORDER BY COLNAME;

Try and reply if it worked....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top