Methods of Sybase querying table structure (similar to the desc of Oracle)

Source: Internet
Author: User
Tags sybase sybase database

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.