Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: How to drop an nonexist table without the error message?
Maggie wrote:
>
> When I write create table script, I always put "drop" first, such as,
> drop table orders;
> create table orders(id number);
>
> I have some tables and indexes need to drop and recreate everyday.
> However, if this is the first time to run the drop and create table, it
> always shows the error that "table or view does not exist" first, and then
> create the table.
> How to drop an nonexist table without the error message?
>
> It really bother me because some scheduling tool will take as the error and
> stop the whole process. Hence, I would like to add some sort of "IF THEN"
> statement that bypass the "DROP" if the table has not created yet. I know
> the MS SQL Server, we run the statement as the following to avoid this
> error:
> if exists (select * from sysobjects where id = object_id(N'[dbo].[Orders]')
> and OBJECTPROPERTY(id, N'IsUserTable') = 1)
> drop table [dbo].[Orders]
> GO
>
> Would you please tell me how it works in the ORACEL. Hope Oracle got this
> piece of beauty as well as MS SQL Server. Please help.
Like this:
set feedback off;
set termout off;
whenever sqlerror continue;
drop table mytable;
whenever sqlerror exit failure;
create table mytable(dummy varchar2(1));
exit success;
Received on Tue May 09 2000 - 00:00:00 CDT
![]() |
![]() |