Skip to content

7.a . Scripts

Sayan Bhattacharya edited this page May 4, 2026 · 4 revisions

Scripts

create a new user. grant create session privilege.

HR have what the privileges and view

view ' desc dba_objects "

image image

Q. HR have whatever tables ,those tables select and insert privileges give a new user and view it. write a script.

ans> select 'grant select,insert on '||owner||'.'||object_name||' to nick;' from dba_objects where owner like 'HR' and object_type like 'TABLE';

image

this is called partly automated script.

after that if we copy this seven lines and paste it. those object privileges granted to nick.

image

how to view what privileges grant HR to NICK user

image image

command is [ select grantee,owner,table_name,grantor,privilege from dba_tab_privs where grantee like 'NICK' and owner like 'HR' ]

image

Q. Now HR's those Table or object privilege have nick , remove from nick. write a script.

select 'revoke '||privilege||' on '||owner||'.'||table_name||' from nick;' from dba_tab_privs where grantee like 'NICK';

image

to off the heading bar command> [ set headind off ]

to off the feedback lable command> [ set feedback off ]

view it

image image

Now Fully automated script process

spool is write something through sql and give a file with path. write something then spool off

image

go to a new tab

image

open that nick_privs.sql file and edit it

image

now execute it

image image

Clone this wiki locally