Below are some Oracle
scripts used in day to day activities note that below script will generate sql
statements and then we need to run those statements
Script to capture object level privileges for schema
set head off
set verify off
set feedback off
set echo off
Select 'grant '||privilege||' on
'||owner||'."'||table_name||'" to '||grantee||';' from dba_tab_privs
where grantor in ('&SCHEMA_NAME');
Script to capture system level privileges for schema
select 'grant '||privilege||' to '||grantee||';'
from dba_sys_privs where grantee in ('&SCHEMA_NAME');
Compile INVALID objects in particular schema
select 'alter '||object_type||' '
||owner||'.'||object_name||' compile;' from dba_objects where status='INVALID'
and owner in (‘&SCHEMA_NAME’);
To
refresh SELECT Role
select 'Grant select on &SCHEMA_NAME.'||object_name|| '
to SELECT_ROLE_NAME;' from dba_objects where owner='&SCHEMA_NAME' and
object_type in ('TABLE','VIEW','SYNONYM','MATERIALIZED VIEW');
To
refresh UPDATE role
select 'Grant insert,update,delete on
SCHEMA_NAME.'||object_name|| ' to UPDATE_SCHEMA_NAME;' from dba_objects where
owner=’SCHEMA_NAME' and object_type in ('TABLE','VIEW','SYNONYM','MATERIALIZED
VIEW')
union
select 'Grant execute on SCHEMA_NAME.'||object_name|| ' to
UPDATE_ROLE_NAME;' from dba_objects where owner='SCHEMA_NAME' and object_type
in ('PROCEDURE','FUNCTION','PACKAGE');
To
Enable and Disable constraints on a table
select 'alter table ' || owner || '.' ||'"'||
TABLE_NAME||'"'|| ' disable constraint ' ||'"'|| CONSTRAINT_NAME
||'"'|| ';' from dba_constraints where OWNER='SCHEMA_NAME';
select 'alter table ' || owner || '.' ||'"'||
TABLE_NAME||'"'|| ' enable constraint ' ||'"'|| CONSTRAINT_NAME
||'"'|| ';' from dba_constraints where OWNER='SCHEMA_NAME';
To
truncate tables of a schema
select 'truncate TABLE ' ||owner||'.'||object_name||';' from
dba_objects where owner='SCHEMA_NAME' and object_type='TABLE' order
by 1 desc;
To
kill the sessions
db
Level
select 'alter system kill session '''||sid
||','||serial#||''';' from v$session where sid in (2331,1552,261);
OS
level
select 'kill -9 '||p.spid from v$session s, v$process p
where s.paddr=p.addr and s.sid in (2331,1552,261);
Synonym
creation on all the tables of particular schema
select 'create synonym '||object_name||' for '
||owner||'.'||object_name||';' from dba_objects where owner in ('SCHEMA_NAME')
and object_type in ('TABLE');
I will keep this article updated with new scripts. Keep eye on this.
Top technologies to learn
ReplyDeleteExcellent blog with lots of information. I have to thank for this. Do share more.
Great Article Artificial Intelligence Projects
DeleteProject Center in Chennai
JavaScript Training in Chennai
JavaScript Training in Chennai Project Centers in Chennai
DevOps Training in Chennai
ReplyDeleteI am glad that I have visited this blog. Really helpful, eagerly waiting for more updates
Nice blog was really feeling good to read it. Thanks for this information.
ReplyDeletedevops interview questions and answers
devops interview questions and answers for experienced
java interview questions for freshers
selenium interview questions and answers pdf download
digital marketing interview questions and answers for freshers
hadoop interview questions and answers pdf
oracle pl sql interview questions
it was so good to read and useful
ReplyDeleteData Science course in Tambaram
Data Science Training in Anna Nagar
Data Science Training in T Nagar
Data Science Training in Porur
Data Science Training in OMR
Data Science course in Chennai
I found so many interesting stuff in your blog especially its discussion. Looking for the best way to enhance your spoken English skills in Kuwait? Look no further than Ziyyara Edutech's exceptional online spoken English classes.
ReplyDeleteFor more info visit Spoken english language Class in kuwait fahaheel
Excellent blog, good to see someone is posting quality information. Thanks for sharing this useful information. Are you facing challenges in speaking English fluently? We have the perfect solution for you with our English language classes and courses in Qatar.
ReplyDeleteFor more info visit English language Class in Qatar
I would like to thank you for the wonderful information. Amazing post!. Join the best online English language courses, embark on a journey to fluency, and watch your language skills soar with us!
ReplyDeleteBook a free demo today. Learn english online in bahrain