如何获取sybase表列名及其数据类型和顺序

时间:2022-10-17 22:57:04

There are multiple table in my sybase database i want to know the column name and datatype of a given table like (myOrder table). How can i do this. Below script i found on * From a Sybase Database, how I can get table description ( field names and types)? . But this gives me exception syscolumns is ambiguous . The script is below that i used for this .

我的sybase数据库中有多个表,我想知道给定表的列名和数据类型,如(myOrder表)。我怎样才能做到这一点。下面我在*上找到的脚本从Sybase数据库,我如何获取表描述(字段名称和类型)? 。但这给了我异常syscolumns是不明确的。脚本低于我用于此的脚本。

SELECT sc.* 
FROM syscolumns sc
INNER JOIN sysobjects so ON sc.id = so.id
WHERE so.name = 'my_table_name'

3 个解决方案

#1


7  

To extract types I am using such query:

要提取类型我正在使用这样的查询:

SELECT syscolumns.name, systypes.name FROM sysobjects 
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON systypes.type = syscolumns.type AND systypes.usertype = syscolumns.usertype
WHERE sysobjects.name LIKE 'my_table' 

#2


4  

To get column names, data types and a lot more info for a table in Sybase, use the following query.

要获取Sybase中的表的列名,数据类型和更多信息,请使用以下查询。

Select * from systabcol
key join systab
 where table_name = 'your_table_name'

#3


0  

Just to add a hopefully useful addition here, I use Sybase's SQL Anywhere 12, so, the syscolumns object(view) does not hold the same information as other versions of Sybase, and therefore requires joining on named information. However, this consolidated view, as it is called, is almost perfectly capable by itself (see it's documentation here).

为了在这里添加一个有希望的有用的补充,我使用Sybase的SQL Anywhere 12,因此,syscolumns对象(视图)不包含与其他Sybase版本相同的信息,因此需要加入命名信息。但是,这个统一的视图,就像它所说的那样,它本身几乎完全有能力(参见这里的文档)。

We in fact use it for checking changes to columns across all tables, as a QA tool, similar to this:

事实上,我们使用它来检查所有表中列的更改,作为QA工具,类似于:

Select * 
    From sys.syscolumns 
    Where (cname Like '%trk%' Or cname Like '%track%') 
    And cname not like '%ontrack%' 
    Order By tname;

#1


7  

To extract types I am using such query:

要提取类型我正在使用这样的查询:

SELECT syscolumns.name, systypes.name FROM sysobjects 
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON systypes.type = syscolumns.type AND systypes.usertype = syscolumns.usertype
WHERE sysobjects.name LIKE 'my_table' 

#2


4  

To get column names, data types and a lot more info for a table in Sybase, use the following query.

要获取Sybase中的表的列名,数据类型和更多信息,请使用以下查询。

Select * from systabcol
key join systab
 where table_name = 'your_table_name'

#3


0  

Just to add a hopefully useful addition here, I use Sybase's SQL Anywhere 12, so, the syscolumns object(view) does not hold the same information as other versions of Sybase, and therefore requires joining on named information. However, this consolidated view, as it is called, is almost perfectly capable by itself (see it's documentation here).

为了在这里添加一个有希望的有用的补充,我使用Sybase的SQL Anywhere 12,因此,syscolumns对象(视图)不包含与其他Sybase版本相同的信息,因此需要加入命名信息。但是,这个统一的视图,就像它所说的那样,它本身几乎完全有能力(参见这里的文档)。

We in fact use it for checking changes to columns across all tables, as a QA tool, similar to this:

事实上,我们使用它来检查所有表中列的更改,作为QA工具,类似于:

Select * 
    From sys.syscolumns 
    Where (cname Like '%trk%' Or cname Like '%track%') 
    And cname not like '%ontrack%' 
    Order By tname;