Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I look at column metadata in Sybase?

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)

like image 419
Jose Avatar asked Apr 06 '09 20:04

Jose


People also ask

How can I get table column names and data types in Sybase?

You can use built-in procedure sp_columns. It will return all the table metadata including column name, data type, column length etc.

What is metadata in Sybase?

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.

What is column metadata?

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.

How do I Desc a table in Sybase?

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.


1 Answers

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

like image 64
tpdi Avatar answered Oct 20 '22 18:10

tpdi