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

前端 未结 4 1003
有刺的猬
有刺的猬 2021-01-07 22:44

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

相关标签:
4条回答
  • 2021-01-07 23:03

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

    Select DBMS_METADATA.GET_DDL('CONSTRAINT', 'CONSTRAINT_NAME') from dual
    
    0 讨论(0)
  • 2021-01-07 23:11

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

    0 讨论(0)
  • 2021-01-07 23:21

    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';
    
    0 讨论(0)
  • 2021-01-07 23:22

    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

    0 讨论(0)
提交回复
热议问题