How to Find the Name of a Constraint in Oracle Database: Oracle Operators: CONSTRAINT PRIMARY KEY FOREIGN KEY UNIQUE DEFAULT CHECK Problem: You want to find the names of the constraints in a table in Oracle. Example: We want to display the names of the constraints in the table student. Solution: select CONSTRAINT_NAME, CONSTRAINT_TYPE, TABLE_NAME from USER_CONSTRAINTS where TABLE_NAME='STUDENT'; Here is the result: CONSTRAINT_NAMECONSTRAINT_TYPETABLE_NAME SYS_C007376RSTUDENT SYS_C007374PSTUDENT SYS_C007375USTUDENT SYS_C007372CSTUDENT Discussion: In Oracle, use the view user_constraints to display the names of the constraints in the database. The column constraint_name contains the name of the constraint, constraint_type indicates the type of constraint, and table_name contains the name of the table to which the constraint belongs. In the column constraint_type, the value “R” is for the foreign key, “P” is for the primary key, “U” is for the uniqueness constraint, and “C” is for the constraint check. In our example, there is a constraint in the table student of the type P (primary key) whose name is SYS_C007374. Recommended courses: The Basics of Creating Tables Data Types in SQL SQL Constraints Recommended articles: What is a Primary Key in SQL? How to Create a Table in SQL Referential Constraints and Foreign Keys in MySQL Understanding Numerical Data Types in SQL See also: How to Create a Primary Key in SQL How to Remove a Primary Key in SQL Subscribe to our newsletter Join our monthly newsletter to be notified about the latest posts. Email address How Do You Write a SELECT Statement in SQL? What Is a Foreign Key in SQL? Enumerate and Explain All the Basic Elements of an SQL Query