数据库删除表语句

判断表存在,执行删除表操作:

mySql:

drop table if exists  tablename


Oracle:

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE tablename';

    EXCEPTION WHEN OTHERS THEN NULL;

END;


SQLServer:

IF EXISTS ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'tablename')


Sysbase(未验证):

if exists(select 1 from sysobjects where name = 'tablename' and type = 'U')  drop table tablename



Syabase(未验证):

if exists(select 1 from sysobjects where name = 'tablename'  and type = 'U')  drop table tablename


DM(未验证):


DB2(未验证):

P1: BEGIN
IF EXISTS (select * from sysibm.systables where TID <> 0 and name = 'tablename')THEN
drop table tablename;
END IF;
END P1


你可能感兴趣的:(数据库删除表语句)