sql - 如何从表中获取列类型?

标签 sql sap-ase

我有这个代码:

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/

相关文章:

sql - 从两个不同的服务器数据库 INSERT INTO

java - 在Java中获取以秒为单位的日期表示

database - sybase系统程序-如何得到结果?

performance - Sybase 15 性能问题

sql - 在 SQL Server 中创建版本化数据并查找版本之间的差异

php - Codeigniter 根据 View 中的 id 在 View 中显示来自 2 个不同表的数据

sql - 按多个维度成员进行 MDX 过滤

mysql - 我可以在 MySQL 数据库字段表达式中运行 MySQL 查询吗?

delphi - Delphi 2010 的 Sybase 驱动程序

SQL 查找相同的组