Oracle导出用户、表空间和角色的创建语句

#!/bin/bash
user=`whoami`
if [ $user != oracle ]; then
echo "must be run as oracle!"
exit 1
fi

test -d /home/oracle/backup
if [ $? -ne 0 ]; then
mkdir -p /home/oracle/backup
fi

sqlplus / as sysdba < 'TEMP';
spool off;

remark create user 
spool /home/oracle/backup/createuser.sql
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','CWKLP','OA','OA88');
spool off

remark create role;
spool /home/oracle/backup/createrole.sql
select 'create role ' || role || ' ;' from  dba_roles where role like 'ROLE%';
spool off
set heading on
set feedback on
set echo on
set termout on
set linesize 100
>>!

 

你可能感兴趣的:(Oracle)