求牛人解答:Oracle判断语句问题
Oracle判断一个表是否存在 若存在则删除它重新建立 若不存在则直接建立
语句改怎么写
[解决办法]
--给个例子declarenum number;beginselect count(1) into num from all_tables where table_name='TESTA';if num>0 thenexecute immediate 'drop table TESTA';end if;execute immediate 'create table TESTA as select * from dept';end;/
[解决办法]
SET serveroutput ON;declare i integer;BEGIN i:=0; SELECT count(*) INTO i FROM user_tables WHERE table_name='TB'; IF i=1 THEN EXECUTE IMMEDIATE 'drop table tb'; dbms_output.put_line('删除成功'); ELSE dbms_output.put_line('删除失败'); END IF;end;