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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying database for columns

Status
Not open for further replies.

mbyrom

Programmer
Feb 28, 2003
4
TR
I'm currently working with an Informix database.
The database is quite large, quite old, and I have only rudimentary knowledge of the tables contained within the database.

I'd like to use some SQL that would check the database for column names

i.e. (search database for tables containing the column name "Line Code")

Is this possible?
 
The following query will list the columns of a table named 'table':
Code:
SELECT sc.colname 
  FROM syscolumns sc, systables st 
 WHERE st.tabid=sc.tabid AND st.tabname='table'
ORDER BY sc.colno
There are more columns in the syscolumns table that define data type, column length, minimum value, and maximum value.

To search for a database containing the column "LineCode", the query would be:
Code:
SELECT st.tabname, sc.colname
  FROM syscolumns sc, systables st
 WHERE st.tabid=sc.tabid and sc.colname='LineCode'
ORDER BY 1
 
Is there a lookup table for an English language description of the 'coltype' field in the syscolumns table?

TIA,
Kerr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top