sql server里可以这样写
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fxjlb]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[fxjlb]
GO
但是oracle里怎么作啊?

解决方案 »

  1.   

    如果确认存在就删除表的话,就直接把删除语句写在建表语句前就可以了,如果表不存在,ora会给出删除失败的信息,继续执行下面的创建表的语句,没有必要判断的亚。
    eg:
    drop table your_table_name;
    create table your table_name
    (column1 varchar2(2)
    );
      

  2.   

    对了,如果你非要判断的话,可以在表fnd_tables中查看该表是否存在,fnd_tables表的字段table_name保存数据库中现有的所有表名
      

  3.   

    在user_tables表中查看该表是否存在
      

  4.   

    如楼上所说,可以这样
    i :=0;
    select count(*) into i from user_tables where table_name ='xxxx';
    if i = 0 then
      create table
    else
      

  5.   

    declare
    num number;
    begin
    select count(1) into num from user_tables where table_name='大写表名';
    if num>0 then
    execute immediate 'drop table '||大写表名;
    end if;
    execute immediate 'create table....';
    end;
    /