java oracle sql语句问题

declare
v_a number(3);
begin

select count(1) into v_a from dba_tablespaces where TABLESPACE_name = 'EPET_TABLESPACE';
if v_a>=1 then
execute immediate 'drop tablespace EPET_TABLESPACE including contents and datafiles;';
end if;
end;
初接触oracle ,请指教。
总是报无效字符。我想判断表空间是否存在,如果存在就删除表空间,以上语句总报错 无法正常运行,请大神给指点一下,或给个正确的程序。谢谢

第1个回答  2013-06-27
你的语句 有问题
execute immediate 'drop tablespace EPET_TABLESPACE including contents and datafiles;';

sql 语句的多了 一个 ‘;’号 改成
execute immediate 'drop tablespace EPET_TABLESPACE including contents and datafiles';
就不会有错了

哈哈 我试过了
第2个回答  2013-06-27
declare
  v_a number(3);
begin 
      
      select count(1) into v_a from dba_tablespaces where TABLESPACE_name = 'MYTBS'; 
      dbms_output.put_line(v_a);
      if   v_a>=1   then 
          execute immediate 'drop tablespace MYTBS including contents and datafiles cascade constraints'; //语句多了个分号,还有一个问题是,你的语句并不能删除表空间的文件,需要加上cascade constraints
      end   if; 
end;

本回答被提问者采纳
第3个回答  2013-06-27
语句没有问题,报错该是因为你的权限不够?
相似回答