First, view the constraint information
1. Use data dictionary user_constraints to view constraint information for a table in user mode
Sql> Select Owner,constraint_name,constraint_type,table_name
2 from User_constraints;
The above SQL statement can query the constraints of each table in user mode
2. Use the data dictionary user_cons_columns to see which column the constraints are defined for each table
sql> Col column_name fora10;
Sql> col owner for A10;
Sql> Select Owner,constraint_name,table_name,column_name
2 from User_cons_columns;
Actual operation:
STEP1: View the table structure of the user_constriants, such as:
STEP2: View constraint information for a table in the current user mode, note the commands in the figure , such as:
STEP3: The above looks a bit troublesome, then revise, Note the command in the diagram , such as:
For example, a line on the Blue Line, there is a constraint named Ck_age, the type is a check constraint, exists in the D table (the first column owner is the user, the second column constraint_name is the constraint name, the third column C is the constraint type, the fourth column table_name is in which table), For constraint types, the R in the diagram represents a foreign key constraint.
Combat Operations 2 (see which column of the table the constraint is in):
STEP1: View the constraint information for the table in the current user mode, which column can be specific, note the commands in , such as:
STEP2: Find a little messy, then format it, pay attention to command Col column_name for A15; This means that the column_name column length is controlled at 15 characters, such as:
STEP3: Find or mess, continue to format words, such as:
than the blue line, you can see that the current user of the D table has two constraints, respectively, in the D table of sex and age two columns, the constraint names are ck_sex and Ck_age respectively.
oracle-17-Data dictionary View constraint information