博客园站长
这是人类成长进步中记录的每一时刻
DECLARE num NUMBER;
BEGIN
SELECT COUNT(1) INTO num FROM USER_TABLES WHERE TABLE_NAME = UPPER('tableName') ;
IF num > 0 THEN
  EXECUTE IMMEDIATE 'DROP TABLE tableName' ;
END IF;
END;

  

 

 

 

多表情况

declare 
num number; 
num1 number;
num2 number;
begin 

SELECT COUNT(1) INTO num FROM USER_TABLES WHERE TABLE_NAME = UPPER('BAK_XX1') ;
SELECT COUNT(1) INTO num1 FROM USER_TABLES WHERE TABLE_NAME = UPPER('BAK_XX2') ;
SELECT COUNT(1) INTO num2 FROM USER_TABLES WHERE TABLE_NAME = UPPER('BAK_XX3') ;
if num=1 then 
execute immediate 'drop table BAK_XX1'; 
end if; 
if num1=1 then 
execute immediate 'drop table BAK_XX2'; 
end if; 
if num1=1 then 
execute immediate 'drop table BAK_XX3';

  

posted on 2016-06-28 17:25  dm3344  阅读(610)  评论(0编辑  收藏  举报