删除表前判断表是否存在SQL

Oracle数据库删除表前判断表是否存在SQL

declare vCount int;
begin
select count(1) into vCount from user_all_tables where Table_name = upper('testtable01');
if(vCount > 0 ) then 
execute immediate ('drop table testtable01');
end if;
end;

SqlServer数据库删除表前判断表是否存在SQL

if exists (select * from dbo.sysobjects where id = object_id(N'testtable01') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table testtable01

PG数据库删除表前判断表是否存在SQL

DROP TABLE IF EXISTS testtable01

DM数据库删除表前判断表是否存在SQL

declare vCount int;
begin
select count(1) into vCount from user_all_tables where Table_name = upper('testtable01');
if(vCount > 0 ) then 
execute immediate ('drop table testtable01');
end if;
end;

Mysql数据库删除表前判断表是否存在SQL

DROP TABLE IF EXISTS testtable01
posted @ 2020-12-14 15:10  还可入梦  阅读(2287)  评论(0编辑  收藏  举报