Domanda

If i use in ASA Sybase database for getting columns:

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

then i can get creator, table_name, column name, column type (varchar, int, ..) but no column id or table id cannot see. How is the query, that i can get columns

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

I meaned, how to get the

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
È stato utile?

Soluzione

I think that sys.syscolumns is a view that is related to ASE compatibility. You probably want to join SYSTAB, and 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

You may have to also reference SYSIDX to get the primary key information.

References to the system tables and their structure can be found in the documentation. In most cases you can use the SQLAnywhere v10 documentation to find answers about Sybase ASA.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top