How to fetch the system generated check constraint name of table column in oracle

前端 未结 1 1247
时光说笑
时光说笑 2021-01-28 15:29

I have created my TEST_TABLE table using below query in oracle

  CREATE TABLE \"PK\".\"TEST_TABLE\" 
   (    \"MYNAME\" VARCHAR2(50),  
      \"MYVA         


        
相关标签:
1条回答
  • 2021-01-28 16:01

    There are two ways. First (recommended) - to give name to constraints when creating it. Second - to search in ALL_CONS_COLUMNS (or USER_CONS_COLUMNS) system view.
    You need something like this:

    select constraint_name
      from all_cons_columns
     where table_name = 'TEST_TABLE'
       and owner = 'PK'
       and column_name = 'MYVAL1'
    

    See documentation: https://docs.oracle.com/cloud/latest/db121/REFRN/refrn20045.htm#REFRN20045

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