SQL query table information in Oracle

Source: Internet
Author: User

In Oracle, SQL queries table information because the data structure design of some modules of the project is not strictly in accordance with a certain specification design, it can only be
To query the data structure, you need to query the following information: field name, data type, whether it is null, default value, primary key, foreign key, and so on. Www.2cto.com searched for the above information on the Internet, summarized as follows: 1. query table Basic Information select utc. column_name, utc. data_type, utc. data_length, utc. data_precision, utc. data_Scale, utc. nullable, utc. data_default, ucc. commentsfrom user_tab_columns utc, user_col_comments uccwhere utc. table_name = ucc. table_name and utc. column_name = ucc. column_name and utc. table_name = 'onlinexls' order by column_id Note: order by column_id indicates that the result is displayed in the order in which the data structure is designed. 2. query the table's primary key www.2cto.com select col. column_namefrom user_constraints con, user_cons_columns colwhere con. constraint_name = col. constraint_name and con. constraint_type = 'p' and col. table_name = 'onlinexls' 3. query the foreign key www.2cto.com select distinct (ucc. column_name) column_name, rela. table_name, rela. column_name column_name1from user_constraints uc, user_cons_columns ucc, (select t2.table _ name, t2.column _ name, t1.r _ constraint_name from user_constraints t1, user_cons_columns t2 where t1.r _ constraint_name = t2.constraint _ name and t1.table _ name = 'onlinexls') relawhere uc. constraint_name = ucc. constraint_name and uc. r_constraint_name = rela. r_constraint_name and uc. table_name = 'onlinexls'

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.