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