Oracle数据库创建表空间及用户并设置权限

declare                    
file_path varchar2(500);    
v_sql varchar2(500);   
begin   
select  distinct substr(FILE_NAME,1,instr(FILE_NAME,'/','-1',1)) into file_path  from dba_data_files t where t.tablespace_name = 'USERS';
dbms_output.put_line(file_path);

------ default tablespace space_test begin------
v_sql:= ' CREATE TABLESPACE  space_test NOLOGGING DATAFILE ' ||''''||file_path||'space_test.dbf'||''''||' SIZE 200M  '
    || 'REUSE AUTOEXTEND  ON NEXT 51200K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO';
  execute immediate v_sql;
------default tablespace test end------


end ;
/

CREATE USER test IDENTIFIED BY "123" DEFAULT TABLESPACE "space_test" TEMPORARY TABLESPACE "TEMP";
commit;
grant connect to test;
grant unlimited tablespace,dba to  test;

你可能感兴趣的:(oracle)