我有这个代码:
select a.id as tableid,
a.name as tableName,
b.name as columnName,
b.status as columnStatus,
b.type as columnType
from sysobjects a
LEFT JOIN syscolumns b
ON a.id = b.id
WHERE a.name = 'table_name'
现在, columType 显示数字。我想获取 columnType 的名称,该名称位于表“systypes”的“name”列中。我怎么做?简单的 LEFT JOIN 将导致重复的行。
最佳答案
我在 Sybase 15.0 中看到过,这是您必须使用的代码:
select o.id [tableid], o.name [tableName], c.name [columnName], c.status [columnStatus], t.name [columnType] from sysobjects o
inner join syscolumns c on c.id = o.id
inner join systypes t on t.usertype = c.usertype
where o.type = 'U' and o.name in ('tablename')
关于sql - 如何从表中获取列类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8550427/