oracle 通过约束名获取表名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5247858/
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
Get table name by constraint name
提问by sergionni
Oracle constraint name is known.
Oracle 约束名称已知。
How do I find the name of the table for which this constraint is applied?
如何找到应用此约束的表的名称?
回答by Justin Cave
SELECT owner, table_name
FROM dba_constraints
WHERE constraint_name = <<your constraint name>>
will give you the name of the table. If you don't have access to the DBA_CONSTRAINTS
view, ALL_CONSTRAINTS
or USER_CONSTRAINTS
should work as well.
会给你表的名字。如果您无权访问该DBA_CONSTRAINTS
视图,ALL_CONSTRAINTS
或者USER_CONSTRAINTS
应该也可以使用。
回答by Suprriya
ALL_CONSTRAINTS
describes constraint definitions on tables accessible to the current user.
ALL_CONSTRAINTS
描述当前用户可访问的表的约束定义。
DBA_CONSTRAINTS
describes all constraint definitions in the database.
DBA_CONSTRAINTS
描述了数据库中的所有约束定义。
USER_CONSTRAINTS
describes constraint definitions on tables in the current user's schema
USER_CONSTRAINTS
描述当前用户模式中表的约束定义
Select CONSTRAINT_NAME,CONSTRAINT_TYPE ,TABLE_NAME ,STATUS from
USER_CONSTRAINTS;
回答by Van Gogh
SELECT constraint_name, constraint_type, column_name
from user_constraints natural join user_cons_columns
where table_name = "my_table_name";
will give you what you need
会给你你需要的