x

How do I find all invalid objects in my database?

Is there an easy query I can run to do this, or some way of finding this out in SQL Developer?

more ▼

asked Oct 30, 2009 at 05:40 AM in Default

David Atkinson gravatar image

David Atkinson
357 15 19 22

(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first
SELECT owner,object_name,subobject_name,object_type FROM all_objects WHERE status='INVALID' 
more ▼

answered Oct 30, 2009 at 07:33 AM

Andrew Mobbs gravatar image

Andrew Mobbs
1.5k 1 3

(comments are locked)
10|1200 characters needed characters left

SQL Developer already includes a custom report for this. Click the custom reports tab, drill down to Data Dictionary Reports -> All Objects -> Invalid Objects Report.

more ▼

answered Oct 30, 2009 at 12:10 PM

dmann gravatar image

dmann
437 1 1 4

(comments are locked)
10|1200 characters needed characters left

I know you mentioned SQL Developer - great tool - but if you are using Toad, the Schema Browser has a tab/category for 'Invalid Objects'. It pulls in everything listed in the above query plus a whole lot more...below is the query. Once the objects come back, you have a button to rebuild/recompile the list of objects as you see fit.

Select owner, object_name, object_type, LAST_DDL_TIME, object_id from sys.DBA_OBJECTS o where status <> 'VALID' and object_type <> 'SYNONYM' UNION ALL Select owner, object_name, object_type, LAST_DDL_TIME, object_id from sys.DBA_OBJECTS where object_type = 'INDEX' and (owner, object_name) in (SELECT owner, index_name FROM sys.DBA_INDEXES WHERE status = 'UNUSABLE' UNION ALL SELECT index_owner, index_name FROM sys.DBA_IND_PARTITIONS ip WHERE status = 'UNUSABLE' UNION ALL SELECT index_owner, index_name FROM sys.DBA_IND_SUBPARTITIONS isp WHERE status = 'UNUSABLE' )

more ▼

answered Nov 03, 2009 at 10:19 AM

HillbillyToad gravatar image

HillbillyToad
1k 2

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x378

asked: Oct 30, 2009 at 05:40 AM

Seen: 7038 times

Last Updated: Oct 30, 2009 at 05:40 AM