How do I look at column metadata in Sybase?

Jose picture Jose · Apr 6, 2009 · Viewed 36.8k times · Source

I have a list of columns a co-worker has given to me, but these columns reside in different tables in the DB. Is there some kind of tool in Sybase where I can query the table a column belongs to?

(I've tried Google-ing for this kind of tool, but no luck so far)

Answer

tpdi picture tpdi · Apr 7, 2009

syscolumns holds column metadata.

select * from syscolumns where name = ;

The id column in syscolumns is the id of the column's table, in sysobjects;

select b.name as tablename, a.name as columnname
from syscolumns a join systables b on (a.id = b.id) 
where b.type='U' and b.name = 'foo';

gets all columns for the table named 'foo'. The type = 'U' limits it to user tables.

select b.name as tablename, a.name as columnname
from syscolumns a join systables b on (a.id = b.id) 
where b.type='U' and a.name = 'foo';

gets all columns named 'foo'.

Most current version of ASE will use sysbojects instead of systables