Skip to content

another way to list invalid objects

How often did I type a query like this to list the invalid objects in a database?

select count(*)
  from dba_objects
 where status  'VALID';
    -- and user in/not in

Today I learned another way to do the same.

Read More

There is a view called dba_invalid_objects. Surprisingly the view is not listed in the official 12c database reference. It is however mentioned in the upgrade guide.
Let’s do some tests. Currently I do not have any invalid objects:

SQL> select count(*) from dba_objects where status  'VALID';

  COUNT(*)
----------
	 0

SQL> select count(*) from dba_invalid_objects;

  COUNT(*)
----------
	 0

SQL> 

I’ll create an invalid procedure:

SQL> create procedure a ( a in number ) as a int; begin 1=1; end;
2 /

Warning: Procedure created with compilation errors.

Is it listed in dba_invalid_objects?

SQL> select OBJECT_NAME from dba_invalid_objects; 
OBJECT_NAME -------------------------------------------------------------------------------- A

Yes. Indeed this is a just a short cut to select from dba_objects:

SQL> r
  1* select TEXT from dba_views where view_name = 'DBA_INVALID_OBJECTS'

TEXT
--------------------------------------------------------------------------------
select "OWNER","OBJECT_NAME","SUBOBJECT_NAME","OBJECT_ID","DATA_OBJECT_ID","OBJE
CT_TYPE","CREATED","LAST_DDL_TIME","TIMESTAMP","STATUS","TEMPORARY","GENERATED",
"SECONDARY","NAMESPACE","EDITION_NAME","SHARING","EDITIONABLE","ORACLE_MAINTAINE
D" from DBA_OBJECTS
where STATUS = 'INVALID' and
  (OBJECT_TYPE != 'TYPE' or (OBJECT_TYPE='TYPE' and SUBOBJECT_NAME is null))

Anyway, good to know.

Seems this view was introduced with Oracle 11gR1.

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Open source Team

Open source Team

Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.View Author posts

721 posts since September 2011

Leave a Comment

Your email address will not be published. Required fields are marked *