Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to detect if an object exists...

Status
Not open for further replies.

seyton

Programmer
Apr 22, 2002
6
US
Here's the problem.
We have developers that will write scripts that get submitted to a DBA in order to be run on a production evironment. Our problem is for instance

insert foo into bar, and Oracle will through an exception when the table bar does not exists.

Is there an easy way to add something to their scripts to see if an object exists.. (sequences, tables, etc.. ).

Thanks.
 
you can use the followign sql to see if the table exists or not -

select count(*) from all_tables where table_name = <table name>

But as per my understanding &quot;all_objects&quot; view will show only the tables owned by the user or given access privilege to that user.
 
It's much easier and much faster to catch the exception. Though select from all_objects may help you

 
If you are the dba (or have rights) you could also do the select on dba_objects (select count(*) from dba_objects where object_name=<table_name>;
 
IMHO, The best approach is to use Developers that know
what exists....Give them Data Models before they waste their time, and your DBA's , writing scripts that access invalid or non-existant opjects...

Just a thought..
[profile]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top