Hank Gay
Hank Gay

Reputation: 71939

How do I find the definition of a named constraint in Oracle?

All I know about the constraint is it's name (SYS_C003415), but I want to see it's definition.

Upvotes: 25

Views: 45879

Answers (4)

Rakesh
Rakesh

Reputation: 4252

Use following query to get a definition of constraint in oracle:

Select DBMS_METADATA.GET_DDL('CONSTRAINT', 'CONSTRAINT_NAME') from dual

Upvotes: 8

cagcowboy
cagcowboy

Reputation: 30828

Another option would be to reverse engineer the DDL...

DBMS_METADATA.GET_DDL('CONSTRAINT', 'SYS_C003415')

Some examples here....

http://www.psoug.org/reference/dbms_metadata.html

Upvotes: 9

Hank Gay
Hank Gay

Reputation: 71939

Looks like I should be querying ALL_CONSTRAINTS.

select OWNER, CONSTRAINT_NAME, CONSTRAINT_TYPE, TABLE_NAME, SEARCH_CONDITION from ALL_CONSTRAINTS where CONSTRAINT_NAME = 'SYS_C003415';

Upvotes: 38

hamishmcn
hamishmcn

Reputation: 7981

Or to see all constaints use SYS.DBA_CONSTRAINTS (If you have the privileges)

Upvotes: 0

Related Questions