Oracle Queries all constraints

Source: Internet
Author: User

PRIMARY KEY constraint
SELECT
User_cons_columns. Constraint_name as constraint name,
User_cons_columns. table_name as table name,
User_cons_columns. column_name as column name,
User_cons_columns. POSITION as Location
From
User_constraints
JOIN User_cons_columns
On (user_constraints. Constraint_name
= User_cons_columns. constraint_name)
WHERE
Constraint_type = ' P ';

FOREIGN KEY constraints
SELECT
User_cons_columns. Constraint_name as constraint name,
User_cons_columns. TABLE_NAME as sub-table name,
User_cons_columns. column_name as child table column name,
User_cons_columns. POSITION as location,
User_indexes. table_name as Main Table name,
User_ind_columns. column_name as Main Table column name
From
User_constraints
JOIN User_cons_columns
On (user_constraints. Constraint_name
= User_cons_columns. constraint_name)
JOIN user_indexes
On (user_constraints. R_constraint_name
= User_indexes. index_name)
JOIN User_ind_columns
On (user_indexes. Index_name = User_ind_columns. index_name)
WHERE
Constraint_type = ' R ';

Other constraints
SELECT
User_cons_columns. Constraint_name as constraint name,
User_cons_columns. table_name as table name,
User_cons_columns. column_name as column name,
User_cons_columns. POSITION as location,
Constraint_type,
Search_condition
From
User_constraints
JOIN User_cons_columns
On (user_constraints. Constraint_name
= User_cons_columns. constraint_name)
WHERE
Constraint_type in (' C ', ' V ', ' O ');

Oracle Queries all constraints

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.