DBA Hub

📋Steps in this guide1/1

Get DDL of all privileges granted to user

set feedback off pages 0 long 900000 lines 20000 pagesize 20000 serveroutput on accept USERNAME prompt "Enter username :" --This line add a semicolon at the end of each statement execute dbms_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true); -- This will generate the DDL for the user and add his objects,system and role grants SELECT DBMS_METADATA.GET_DDL('USER',us

oracle configurationintermediate
by OracleDba
13 views
1

Get DDL of all privileges granted to user

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
set feedback off pages 0 long 900000 lines 20000 pagesize 20000 serveroutput on
accept USERNAME prompt "Enter username :"
--This line add a semicolon at the end of each statement
execute dbms_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
-- This will generate the DDL for the user and add his objects,system and role grants
SELECT DBMS_METADATA.GET_DDL('USER',username) as script from DBA_USERS where username='&username'
UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT',grantee)as script from DBA_SYS_PRIVS where grantee='&username' and rownum=1
UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT',grantee)as script from DBA_ROLE_PRIVS where grantee='&username' and rownum=1
UNION ALL
SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT',grantee)as script from DBA_TAB_PRIVS where grantee='&username' and rownum=1;

Comments (0)

Please to add comments

No comments yet. Be the first to comment!