首页 > 数据库 > Oracle > 复制创建已有数据库用户、表空间、权限的脚本
remark create tablespace ;
Select 'create TABLESPACE ' || tablespace_name || ' DATAFILE ' || ''''|| file_name || '''' ||' SIZE ' || to_char(ROUND(bytes/1024/1024,0)) ||'M REUSE AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED ;' from dba_data_files
where tablespace_name not in ('SYSTEM','USERS','UNDOTBS1','SYSAUX');
remark create tempfile tablespace ;
Select 'create TABLESPACE ' || tablespace_name || ' DATAFILE ' || ''''||file_name||'''' ||' SIZE ' || to_char(ROUND(bytes/1024/1024,0)) ||'M REUSE AUTOEXTEND ON NEXT 32M MAXSIZE UNLIMITED ;' from dba_temp_files
where tablespace_name <> 'TEMP';
spool off;
remark create user ;
select 'create user '|| username || ' identified by ''change to your password'' default tablespace '|| DEFAULT_TABLESPACE || ' TEMPORARY TABLESPACE ' || TEMPORARY_TABLESPACE ||';'
from dba_users where username not in ('SYS','SYSTEM','SCOTT','DBSNMP');
spool off
remark create role;
spool /home/oracle/backup/createrole.sql
select 'create role ' || role || ' ;' from dba_roles where role like 'ROLE%';
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69994536/viewspace-2761392/ ,如需转载,请注明出处,否则将追究法律责任。