如何在 Oracle 上查看 Check Constraint 的内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2686353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:32:09  来源:igfitidea点击:

How to see contents of Check Constraint on Oracle

oracleconstraints

提问by Chris

I did not create the database I'm working with, but I would like to see the details of a check constraint.

我没有创建我正在使用的数据库,但我想查看检查约束的详细信息。

I know a check constraint on a column is enforcing a set of specific values, and I'd like to know what those values are. For example, if a check constraint is enforcing the character 'Y' and 'N', I want to be able to query the database and see that the accepted values are 'Y' and 'N.'

我知道列上的检查约束正在强制执行一组特定值,我想知道这些值是什么。例如,如果检查约束强制使用字符“Y”和“N”,我希望能够查询数据库并查看接受的值为“Y”和“N”。

Is this possible to do through a query?

这可以通过查询来完成吗?

回答by DBA

select constraint_name,search_condition 
from all_constraints
where table_name='NAME_OF_YOUR_TABLE'
and constraint_type='C';

Will list the check and the constraint name of all check constraints on a specific table.

将列出特定表上所有检查约束的检查和约束名称。

回答by Matt

Don't forget that the columns in the all_constraintstable are case-sensitive. If your select statement returns nothing, that may be why.

不要忘记表中的列all_constraints区分大小写。如果您的 select 语句不返回任何内容,这可能就是原因。

(If I had enough rep to comment, on DBA's answer, this would go there.)

(如果我有足够多的代表发表评论,在 DBA 的回答中,这会去那里。)