删除表前判断表是否存在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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM