ORACLE: primary key, foreign key, Uniqueness constraint, and index of the query (View) Table

Source: Internet
Author: User

ORACLE: primary key, foreign key, Uniqueness constraint, and index of the query (View) Table

1To search for all indexes of a table (including index names, types, and columns ):
Select T. *, I. index_type from user_ind_columns T, user_indexes I where T. index_name = I. index_name and T. table_name = I. table_name and T. table_name =
Table Name

2, Query the table's primary key (including the name, which constitutes a column ):
Select cu. * From user_cons_columns Cu, user_constraints au where cu. constraint_name = Au. constraint_name and AU. constraint_type = 'p' and AU. table_name =
Table Name

3And query the uniqueness constraints of a table (including names and columns ):
Select column_name from user_cons_columns Cu, user_constraints au where cu. constraint_name = Au. constraint_name and AU. constraint_type = 'U' and AU. table_name =
Table Name

4To find the table's Foreign keys (including names, referenced table names, and corresponding key names ):
Select * From user_constraints c Where C. constraint_type = 'r' and C. table_name =
Table Name

Name of the column with foreign key constraints:
Select * From user_cons_columns Cl where Cl. constraint_name =
Foreign key name

Name of the column that references the table key:
Select * From user_cons_columns Cl where Cl. constraint_name =
Foreign key reference table key name

5Query all the columns and their attributes of the table:
Select T. *, C. Comments 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 =
Table Name

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.