Recreate multiple user in Oracle Database
set long 50000
set linesize 1000
col COMMAND for a1000
set pages 50000
spool user_details.sql
SELECT 'CREATE USER ' || u.name ||
' IDENTIFIED BY VALUES ''' || u.spare4 || '''' ||
' DEFAULT TABLESPACE ' || d.default_tablespace ||
' TEMPORARY TABLESPACE ' || d.temporary_tablespace ||
' PROFILE ' || d.profile || ';' as COMMAND
FROM sys.user$ u
JOIN dba_users d ON u.name = d.username
WHERE u.name in ('username');
spool off
set linesize 1000
col COMMAND for a1000
set pages 50000
spool user_details.sql
SELECT 'CREATE USER ' || u.name ||
' IDENTIFIED BY VALUES ''' || u.spare4 || '''' ||
' DEFAULT TABLESPACE ' || d.default_tablespace ||
' TEMPORARY TABLESPACE ' || d.temporary_tablespace ||
' PROFILE ' || d.profile || ';' as COMMAND
FROM sys.user$ u
JOIN dba_users d ON u.name = d.username
WHERE u.name in ('username');
spool off
spool sys_role.sql
select 'grant '||privilege|| ' to '|| grantee || ';' from dba_sys_privs where grantee in ('username');
spool off
select 'grant '||privilege|| ' to '|| grantee || ';' from dba_sys_privs where grantee in ('username');
spool off
spool role_role.sql
select 'grant '||GRANTED_ROLE || ' to '|| grantee ||';' from dba_role_privs where GRANTEE in ('username');
spool off
select 'grant '||GRANTED_ROLE || ' to '|| grantee ||';' from dba_role_privs where GRANTEE in ('username');
spool off
Comments
Post a Comment