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

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

Get table name by constraint name

oracleconstraints

提问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_CONSTRAINTSview, ALL_CONSTRAINTSor USER_CONSTRAINTSshould work as well.

会给你表的名字。如果您无权访问该DBA_CONSTRAINTS视图,ALL_CONSTRAINTS或者USER_CONSTRAINTS应该也可以使用。

回答by Suprriya

ALL_CONSTRAINTSdescribes constraint definitions on tables accessible to the current user.

ALL_CONSTRAINTS描述当前用户可访问的表的约束定义。

DBA_CONSTRAINTSdescribes all constraint definitions in the database.

DBA_CONSTRAINTS描述了数据库中的所有约束定义。

USER_CONSTRAINTSdescribes 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

会给你你需要的