SQL 如何检查Oracle中的数据库对象是表还是视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31853558/
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
How to check if a database object in Oracle is a table or view
提问by Andrew
I have list of object names from which i have to find out whether the object is a table or view. For this reason i have to query and check in all_tables and all_views and confirm whether the object is table or view. I am using below queries and its working. But as i have huge list of object names I want to perform this in single query and check whether the object is table or view and also the owner of the object.
我有对象名称列表,我必须从中找出对象是表还是视图。为此,我必须查询和检查 all_tables 和 all_views 并确认对象是表还是视图。我正在使用以下查询及其工作。但是由于我有大量的对象名称列表,我想在单个查询中执行此操作并检查对象是表还是视图以及对象的所有者。
select * from ALL_views where view_name like '%INSTANCE%'
select * from all_tables where table_name like '%INSTANCE%'
回答by MarioAna
select *
from all_objects
where object_name like '%INSTANCE%'
There is an OBJECT_TYPE column in there.
那里有一个 OBJECT_TYPE 列。
回答by Boneist
How about using all_objects instead?
改用 all_objects 怎么样?
E.g.:
例如:
select owner,
object_name,
object_type
from all_objects
where object_type in ('TABLE', 'VIEW')
and object_name in (....);