Query for all field names in a table with known table names in Oracle, whether each field is a primary key, a foreign key, or an empty SQL statement

Source: Internet
Author: User

Query all columns and their properties for a table:
Select
From User_tab_columns t,user_col_comments C
where t.table_name = c.table_name and T.column_name = c.column_name and t.table_name = women;
To find the primary key for a table:



Find the foreign key of the table (including the name, the table name of the reference table, and the corresponding key name, which are divided into multi-step queries):
SELECT * from user_constraints c where c.constraint_type = ' R ' and c.table_name = women
Query the column name of the FOREIGN KEY constraint:
SELECT * from User_cons_columns cl where cl.constraint_name = foreign key name;
Query the column name of the key referencing the table:
SELECT * from User_cons_columns cl where cl.constraint_name = key name of the foreign key reference table;

Query for all field names in the table with known table names in Oracle, whether each field is a primary key, is a foreign key, or is an empty SQL statement

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.