After many times I have verified. Finally, we found a way to query the database structure in Sybase.
Before that, I was very puzzled about how this Sybase database is not as easy as Oracle and MySQL.
DESC table name;
After the online query, get a result.
sp_help table name;
But there are multiple results. Although there is the result we want. But we just take one, and we're still in the middle.
What do we do? Look at the stored procedure source code. Intercept the results we want.
sp_help stored procedures in the Sybsystemprocs library,
Source:
The code is too long, omitted here ...
One line of inference, look down.
We send the source code of 556 lines "if (@sysstat &) in (1, 2, 3)" Has the result we want, the IF statement is to insert a table result query after a temporary table #helptype, and then query out.
let's not be so troublesome. just take the three columns inside: Field name, field type. The field length.
Of course you want to encapsulate it as a stored procedure, but you can't use Desc.
Select IsNull (c.name, ' NULL ') ' Field name ', T.name ' field type ', c.length ' field length ' from syscolumns C, systypes T, sysxtypes xwhere c.id = ob ject_id (' table name ') and C.usertype *= t.usertypeand c.xtype *= X.xtid;
Methods of Sybase querying table structure (similar to the desc of Oracle)