複製建立已有資料庫使用者、表空間、許可權的指令碼

zhcunique發表於2021-03-05

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部落格 ” ,連結:http://blog.itpub.net/69994536/viewspace-2761392/,如需轉載,請註明出處,否則將追究法律責任。

相關文章