简体   繁体   English

如何使用 SQL 在 Sybase ASE 中获取列的类型

[英]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":给定一个名为“fruit”的表和一个名为“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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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