<%sql="if exists (select * from sysobjects where id = object_id(N'[dbo].[phone]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[phone]"
con.execute(sql)
%>
如果表phone存在则删除phone表
其中phone是表名,con是connection对像
------------------------------------------------------------------------
1.create the test table.
SQL> create table test(fld1 number(1));
Table created.
2.Drop the table
SQL> declare
2 strsql varchar2(100);
3 count1 number(1);
4 begin
5 select count(*) into count1 from user_tables where table_name='TEST';
6 if count1>0 then
7 strsql:='Drop table TEST';
8 execute immediate strsql;
9 end if;
10 end;
11 /
PL/SQL procedure successfully completed.
3.Check
SQL> select count(*) from user_tables where table_name='TEST';
COUNT(*)
----------
0
Trackback: http://tb.donews.net/TrackBack.aspx?PostId=138904