Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Test for the exsistance of a table
"Philip Morrow" <cracker_at_mymorrow.com> wrote in message news:<3c5i8.78860$TV4.13070960_at_typhoon.tampabay.rr.com>...
> Is there a way to test for the exsistance of a table with SQL code. I need
> to test to see if a table exsists and if so drop it. If it doesn't the drop
> table statement doesn't need to be executed.
>
> Thanks for the help.
>
> Phil
Phil, Oracle comes with something referred to in the documentation as the rdbms data dictionary tables. If an object exists and you have privilege to it you can see it in the all_xxx views.
Example:
UT1> set echo on UT1> set serveroutput on UT1> declare 2 -- 3 v_return boolean ;
31 then dbms_output.put_line('Found EMP ') ; 32 else dbms_output.put_line('Did not find EMP ') ; 33 end if ; 34 v_return := test_tbl_exists('MPOWEL01','XXX') ; 35 if v_return 36 then dbms_output.put_line('Found XXX ') ; 37 else dbms_output.put_line('Did not find XXX ') ;38 end if ;
PL/SQL procedure successfully completed.
HTH
-- Mark D Powell --
Received on Fri Mar 08 2002 - 13:58:58 CST