Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Drop table
Hi,
in PL/SQL you could use native dynamic SQL to drop a (potentially inexistent) table and then catch the respective exception:
PROCEDURE drop_table
( table_name varchar2
)
IS
table_inexistent exception; -- table does not exists PRAGMA EXCEPTION_INIT (table_inexistent,-942); -- associate with error ORA-00942
BEGIN execute immediate 'drop table '||insert_table;
EXCEPTION
when table_inexistent then return;
END drop_table;
Hope that helps.
Marco.
petr_kucera_at_my-deja.com wrote:
>
> Is there a way how to drop a table in Oracle DB, but I'd like to check
> if this table alredy exists in database?
> Something like this:
>
> if exists(select * from user_tables where table_name='mytable') then
> drop table mytable;
> end if;
>
> but I can't use DDL statements.
>
> ThanX.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
Marco P O E T K E University of Munich (LMU) tel: +49-89-2178-2229 Institute for Computer Science fax: +49-89-2178-2192 Oettingenstr. 67, D-80538 Muenchen
marco_at_dbs.informatik.uni-muenchen.de
http://www.dbs.informatik.uni-muenchen.de
Received on Mon Feb 21 2000 - 07:36:15 CST