Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PLSQL: how to test if a table exists?
More code + Dynamic SQL = more work for Oracle, and as a result, slower
code. As well as this, the use of Native Dynamic SQL outlined here does
not use Bind Variables.
Personally, I would query the data dictionary, and I believe all_tables will have a list of all tables that you have access to. Alternatively, you can declare a table with Definer Rights (Ie The code is executed as the owner of the procedure, as opposed to the user who is running the procedure).
The Data Dictionary is supposed to be optimised for quick access, so I would personally favour this approach.
"mcstock" <mcstock @ enquery .com> wrote in message
news:o46dnXJiS5uHA1KiRVn-gQ_at_comcast.com...
> "Sybrand Bakker" <gooiditweg_at_sybrandb.demon.nl> wrote in message
> news:b75vsvkhgqodojbvkifd245daqdqidj1c5_at_4ax.com...
> | On Thu, 4 Dec 2003 14:58:58 +0100, "NoName" <nobody_at_nowhere.com>
> | wrote:
> |
> | >Thanks to everybody.
> | >Using your suggestions, I produced the following code:
> | >
> | >declare
> | > c numeric;
> | >begin
> | > select count(*) into c from user_tables where table_name =
'TABLEXY';
> | > if c > 0 THEN
> | > -- statements to do
> | > end if;
> | >end;
> | >
> | >Hope this could help other newbies :-)
> | >Regards
> | >
> |
> | They would better trust appropiate exception handling and not trust
> | this horrible approach.
> |
> |
> | --
> | Sybrand Bakker, Senior Oracle DBA
>
>
>
>
>
> > > > >Received on Thu Dec 04 2003 - 16:14:29 CST