我下面的代码目的是写一个存储过程,创建5个功能一样表空间名则分别为lee_tablespace_1~lee_tablespace_5
运行时有错 不知道具体错在哪里
请教达人~
create or replace procedure create_tablespace
as
i number;
begin
i:=1;
loop
create tablespace 'lee_tablespace_'||i
datafile '/var/oracle/oradata/db0/lee_tablespace_t'||i||'.dat' 
size 1500m autoextend on
default storage (initial 1000m next 50m minextents 1 maxextents unlimited pctincrease 
i:=i+1;
if i>5 then
exit
end if
end loop
end

解决方案 »

  1.   


    PLS-00103: 出现符号 "CREATE"在需要下列之一时:
     ( begin case declare
       exit for goto if loop mod null pragma raise return select
       update while with <an identifier>
       <a double-quoted delimited-identifier> <a b
      

  2.   

    建表语句肯定要用动态SQL的
    更别说你这还是动态拼接的呢
      

  3.   

    create or replace procedure create_tablespace
    as
    i number;
    temp_sql varchar(2000);
    begin
    i:=1;
      loop
        temp_sql:='create tablespace ''lee_tablespace_'''||to_char(i)||'
                   datafile ''/var/oracle/oradata/db0/lee_tablespace_t'''||to_char(i)||'''.dat'' 
                   size 1500m autoextend on
                   default storage (initial 1000m next 50m minextents 1 maxextents unlimited pctincrease ';    execute immediate temp_sql;
       i:=i+1;
       if i>5 then
         exit;
       end if;
      end loop;
    end