简体   繁体   中英

How to get the type of a column in Sybase ASE using SQL

我可以使用什么 SQL 来获取 Sybase ASE 中的列类型?

Within any database you could use special stored procedure

sp_columns '<tableName>', null, null, '<colName>'

and of course, to display all columns with extensive info about them for given table:

sp_columns '<tableName>'

Given a table named "fruit" and a column named "color":

select obj.name as "table", col.name as "column", type.name as "type"
  from sysobjects obj
  join syscolumns col on obj.id=col.id
  join systypes type on col.type=type.type and col.usertype = type.usertype
 where obj.type = "U"               -- means 'U'ser table
   and user_name(obj.uid) = 'dbo'   -- or whatever the user is who owns/created the table
   and obj.name = 'fruit' 
   and col.name = 'color'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM