H2:
-- 测试版本: 1.4.193
create table a_tb(id varchar(32));
drop table if exists a_tb;
MSSQL:
-- 测试版本: SQLServer 2008R2
create table a_tb(id varchar(32));
if object_id(N'dbo.a_tb', N'U') is not null
drop table dbo.a_tb;
MySQL:
-- 测试版本: 5.0.67
create table a_tb(id varchar(32));
drop table if exists a_tb;
Oracle:
-- 测试版本号: 11.2.0.1.0 - 64bit
-- 创建表
create table a_tb(id varchar(32));
-- 查询表及所属用户
select owner,table_name from all_tables where table_name=upper('a_tb'); -- EPN_BIZ,A_TB
-- 删除该用户下的表
declare table_exist int;
begin
select count(*) into table_exist from all_tables
where owner=upper('epn_biz') and table_name=upper('a_tb');
if table_exist = 1 then
execute immediate 'drop table epn_biz.a_tb';
end if;
end;
参考文献: Oracle: If Table Exists