0

For constraint validation i want to read unique key and not null column from oracle11g, I could able to retrieve same from Mysql but don't know how to do it in Oracle 11g

Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124

1 Answers1

0

You need to join [DBA|ALL|USER]_CONSTRAINTS view with [DBA|ALL|USER]_CONS_COLUMNS view.

NOT NULL constraint is type C. UNIQUE constraint is type U.

SELECT a.table_name,
  b.column_name,
  a.constraint_type
FROM dba_constraints a
JOIN dba_cons_columns b
ON a.owner             = b.owner
AND a.constraint_name  = b.constraint_name
AND a.table_name       = b.table_name
AND a.owner            ='<user_name>'
AND a.constraint_type IN ('U', 'C');
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124