0

如果我在 ASA Sybase 数据库中使用获取列:

select * from sys.syscolumns where table_id='1';

然后我可以获得创建者、表名、列名、列类型(varchar、int、..)但没有列 ID 或表 ID 看不到。查询如何,我可以获得列

creator, tname, cname, table_id, coltype, nulls, width, is_primary_key, default_value, remarks

我的意思是,如何获得

select 
    t.creator, //i meaned schema name e.g public
    t.table_name, //the name of table e.g products
    t.table_id, //table's identifier
    c.column_name, //the name of  column, e.g price 
    c.column_type, //e.g varchar(255), integer, ..
    c.nulls, //not null or nulls
    c.width, //255 (varchar(255)), 4 (int(4))
    c.default //default value, the "default" is keyword and gives an error
  from sys.systab t, sys.systabcol c
where t.table_id = c.table_id
4

1 回答 1

2

我认为 sys.syscolumns 是一个与 ASE 兼容性相关的视图。您可能想加入 SYSTAB 和 SYSTABCOL。

select t.creator, t.table_name, t.table_id, c.column_type, c.nulls, c.width, c.default
  from sys.systab t, sys.systabcol c
where t.table_id = c.table_id

您可能还必须参考 SYSIDX 来获取主键信息。

可以在文档中找到对系统表及其结构的引用。在大多数情况下,您可以使用 SQLAnywhere v10 文档来查找有关 Sybase ASA 的答案。

于 2014-03-12T14:58:50.160 回答