如何在Oracle中找到对象的所有者?

编程入门 行业动态 更新时间:2024-10-27 04:26:22
本文介绍了如何在Oracle中找到对象的所有者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想查找表的外键,但是可能有多个用户/模式具有相同名称的表.如何找到当前登录用户正在查看的用户?是否有赋予其所有者的功能?如果有公共同义词怎么办?

I want to find the foreign keys of a table but there may be more than one user / schema with a table with the same name. How can I find the one that the currently logged user is seeing? Is there a function that gives its owner? What if there are public synonyms?

推荐答案

您可以查询ALL_OBJECTS视图:

You can query the ALL_OBJECTS view:

select owner , object_name , object_type from ALL_OBJECTS where object_name = 'FOO'

要查找同义词:

select * from ALL_SYNONYMS where synonym_name = 'FOO'

仅需澄清一下,如果 user 用户的SQL语句引用了没有模式限定(例如'FOO')的对象名称,则Oracle FIRST会在用户的模式中检查该名称的对象(包括同义词)在该用户的模式中).如果Oracle无法从用户的架构中解析引用,则Oracle将检查是否有公共同义词.

Just to clarify, if a user user's SQL statement references an object name with no schema qualification (e.g. 'FOO'), Oracle FIRST checks the user's schema for an object of that name (including synonyms in that user's schema). If Oracle can't resolve the reference from the user's schema, Oracle then checks for a public synonym.

如果您要特别查找对特定table_name的约束:

If you are looking specifically for constraints on a particular table_name:

select c.* from all_constraints c where c.table_name = 'FOO' union all select cs.* from all_constraints cs join all_synonyms s on (s.table_name = cs.table_name and s.table_owner = cs.owner and s.synonym_name = 'FOO' )

HTH

-附录:

如果授予用户访问DBA_视图的权限(例如,如果授予用户SELECT_CATALOG_ROLE权限),则可以在前面的SQL示例中用"DBA_"代替"ALL_". ALL_x视图仅显示已被授予特权的对象. DBA_x视图将显示所有数据库对象,无论您是否拥有这些对象的权限.

If your user is granted access to the DBA_ views (e.g. if your user has been granted SELECT_CATALOG_ROLE), you can substitute 'DBA_' in place of 'ALL_' in the preceding SQL examples. The ALL_x views only show objects which you have been granted privileges. The DBA_x views will show all database objects, whether you have privileges on them or not.

更多推荐

如何在Oracle中找到对象的所有者?

本文发布于:2023-11-29 19:28:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647403.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所有者   对象   中找到   如何在   Oracle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!