How to obtain the details of a user table in DB2

Source: Internet
Author: User

How to obtain the details of a user table in DB2

1. Get the User Name of the current user

SELECT CURRENT SCHEMA FROM SYSIBM.SYSDUMMY1

2. Obtain the names of all tables under a user.

Select creator, TYPE, NAME, remarks from sysibm. Variables Ables where type = 'T' and creator = 'username' -- case sensitive

3. Obtain the details of a table under the current user.

Select t. TBNAME, -- table name T. NAME, -- field name t. REMARKS, -- Chinese name of the Field T. COLTYPE, -- field type T. LENGTH, -- field length t. SCALE, -- precision T. NULLS -- whether it is null from sysibm. syscolumns t where tbcreator = 'username' and tbname = 'table name'

4. Obtain information about all tables and fields of the current user.

Select. TBNAME, -- English name of the table B. REMARKS, -- Chinese table name B. TYPE, -- object type. COLNO, --. NAME, -- the English NAME of A field. REMARKS, -- Chinese name of the field. COLTYPE, -- field type. LENGTH, -- length. SCALE, -- precision. NULLS, -- whether to allow null C. PK_NAME, -- primary key name C. KEY_SEQ, -- primary key sequence C. COLUMN_NAME -- primary key field name from sysibm. syscolumns a -- Field List table left join sysibm. systables B -- table remarks table (Chinese name of the table) ON. TBCREATOR = B. creator and. TBNAME = B. name left join sysibm. sqlprimarykeys c on. TBCREATOR = C. TABLE_SCHEM and. TBNAME = C. TABLE_NAME and. NAME = C. COLUMN_NAME where B. TYPE = 'T' and. TBCREATOR = 'username' -- TYPE = T: table v: vieworder by. TBCREATOR,. TBNAME,. COLNO

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.