Oracle query Table primary KEY, foreign key

Source: Internet
Author: User

Some SQL (under Oracle) summaries used in the project: 1. Find all indexes of the table (including index name, type, constituent column)

  1 Select T.*,i.index_type from User_ind_columns t,user_indexes i where t.index_name = I.index_name and T.tab Le_name = i.table_name and t.table_name = table to query
2. lookup table's primary key (including name, constituent column)
  1 Select cu.* from User_cons_columns cu, user_constraints au where cu.constraint_name = Au.constraint_name A nd au.constraint_type = 'P' and au.table_name = table to query
3, find the uniqueness of the table constraints (including the name, the constituent column)
  1 Select column_name from User_cons_columns cu, user_constraints au where cu.constraint_name = Au.constrain T_name and Au.constraint_type = 'U' and au.table_name = table to query
4, the lookup table of foreign keys (including the name, the table name of the reference table and the corresponding key name, the following is divided into multi-step query) query table information
  1 a) SELECT * from user_constraints c where C.constraint_type = 'R' and c.table_name = table to query
Querying column names for foreign KEY constraints
  1 B) select * from User_cons_columns cl where cl.constraint_name = FOREIGN key Name
Query the column name of the key referencing the table
  1 C) SELECT * from User_cons_columns cl where cl.constraint_name = foreign key reference table key name
5. Querying all columns of the table and their properties
  1 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 to query   2

Oracle query Table primary KEY, foreign key

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.