Oracle 建表空间

/*
*app 创建表空间,大小为50M,自动扩展10M
*pram table_num(表数量),start_num(表空间开始编号),tbs_num(每张表表空间数)
*/
create or replace procedure ctbs(table_num in number ,start_num in number,tbs_num in number) authid current_user is
str_tbs varchar2(4000);
str_max varchar2(1000);
data_file varchar2(200);
begin
data_file := 'D:\oracle\product\10.2.0\oradata\FDB\XPP\';
<<outer>>
for k in 0..table_num-1 loop
<<inner>>
for i in start_num .. tbs_num-1 loop
str_tbs := 'create tablespace P_' || LTRIM(TO_CHAR(k*tbs_num+i, '099')) ||
' datafile ' || chr(39) ||data_file||'P_' ||
LTRIM(TO_CHAR(k*tbs_num+i, '099')) || '.dbf' || chr(39) ||
' size 600M
autoextend on next 10M maxsize unlimited logging
extent management local autoallocate
segment space management auto';
execute immediate str_tbs;
end loop inner;
end loop outer;
for k in 0..table_num-1 loop
str_max := 'create tablespace P_' || LTRIM(TO_CHAR(k, '099')) ||'max'||
' datafile ' || chr(39) ||data_file||'P_' ||
LTRIM(TO_CHAR(k, '099')) || 'max.dbf' || chr(39) ||
' size 500M
autoextend on next 10M maxsize unlimited logging
extent management local autoallocate
segment space management auto';
execute immediate str_max;
end loop;
end ctbs;
/

set serveroutput on size 1000000
begin
ctbs(1,0,100);
end;
/

你可能感兴趣的:(oracle)