Skip to content

Commit 262a249

Browse files
David FRANCODavid FRANCO
authored andcommitted
Created a the get grants scripts and added the possibility of passing parameter to the other 2
1 parent f77b4da commit 262a249

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

createUser.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
set serveroutput on size unlimited
22
set feedback on
33

4+
var v_owner varchar2(30);
5+
6+
exec :v_owner := '&1';
7+
48
DECLARE
59
TYPE NamesList IS TABLE OF VARCHAR2(30); -- nested table type
610
usernames NamesList := NamesList(
7-
'USER_847448','USER_928866','USER_993233','USER_886618','USER_A34104'
11+
:v_owner
812
);
913
tempTbsName VARCHAR2(50);
1014
v_count NUMBER;
@@ -55,4 +59,4 @@ BEGIN
5559
END;
5660
/
5761

58-
--exit;
62+
exit;

getDesyncSequences.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ SET FEEDBACK ON
44

55
var v_owner varchar2(30);
66

7-
exec :v_owner := '&1';
7+
exec :v_owner := upper('&1');
88

99
DECLARE
1010
DIFF NUMBER;

getGrants.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Get all grants of a specific user, could be done with the get_ddl to, but this way is easier to
2+
-- adapt from getting the grants of a user to a table, role or etc.
3+
4+
var v_owner varchar2(30);
5+
6+
exec :v_owner := '&1';
7+
8+
select 'grant '||granted_role||' to '||grantee||';'
9+
from dba_role_privs
10+
where grantee in (:v_owner)
11+
union all
12+
select 'grant '||privilege||' to '||grantee||';'
13+
from dba_sys_privs
14+
where grantee in (:v_owner)
15+
union all
16+
select 'grant '||privilege||' on '||owner||'.'||table_name||' to '||grantee||';'
17+
from dba_tab_privs
18+
where grantee in (:v_owner)
19+
;
20+
21+
exit

0 commit comments

Comments
 (0)