在ms sql2000里面可以这样判断一个表是否存在,然后把他删除.
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TABLE2]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[TABLE2]再oracle里面怎么写语句?
if exists(select * from sys.all_all_tables where table_name='要删的表名')
then
drop table 要删的表名 ;
end if
??
我用这个在PLSQLDev里面执行不能!!

解决方案 »

  1.   

    oracle里没有if exists语句需要自己判断
    select count(1) from all_tables where table_name='table' and owner='user'如果返回0表示没有该表
      

  2.   

    select count(1) into tempcount from all_tables where table_name='table' and owner='user'if tempcount >0
    then
      drop table ?
    end if这样吗?
      

  3.   

    NinGoo(宁哥 http://NinGoo.itpub.net)是对的.
      

  4.   

    每个数据库的SQL语句都是有区别的.
    在ORACLE 中判断表的存在一般如下:
    select count(*) into tempcount
    from   tab
    where  TNAME = 'xxx' ;
    if tempcount >0
    then
      ---在SQL中使用DLL语句需要使用动态SQL
      execute immediate 'drop table xxxx';
    end if ;
    前提 你有DROP这个表的权限;