How to check if a database object in Oracle is a table or view

28,568

Solution 1

select *
  from all_objects 
 where object_name like '%INSTANCE%'

There is an OBJECT_TYPE column in there.

Solution 2

How about using all_objects instead?

E.g.:

select owner,
       object_name,
       object_type
from   all_objects
where  object_type in ('TABLE', 'VIEW')
and    object_name in (....);
Share:
28,568
Andrew
Author by

Andrew

Updated on July 05, 2022

Comments

  • Andrew
    Andrew almost 2 years

    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.

    select * from ALL_views where view_name like '%INSTANCE%'
    
    select * from all_tables where table_name like '%INSTANCE%'