数据库删除表语句

来源:互联网 发布:mysql执行存储过程 编辑:程序博客网 时间:2024/04/28 13:31

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

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


0 0