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)
You can use built-in procedure sp_columns. It will return all the table metadata including column name, data type, column length etc.
To support JDBC DatabaseMetaData methods, Sybase provides a set of stored procedures that jConnect can call for metadata about a database. These stored procedures must be installed on the server for the JDBC metadata methods to work.
Column metadata attributes provide important details about the data which the column contains. Many open data portals include the necessary tools to create column metadata when publishing new data. Name: Human-readable name of the column. It should be in plain English and usually a word, or a few words at the most.
Use DESCRIBE TABLE to list all the columns in the specified table or view. The DESCRIBE TABLE statement returns one row per table column, containing: Column The name of the column. Type The type of data in the column.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With