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