Posts

Showing posts from December, 2020

Day -DBA scripts-fragmentation

set head off set feedback off spool kill_&a_sess_i1.sql select 'spool kill_&a_sess.log' from dual; select 'set feedback on' from dual; select 'alter system kill session '||chr(39)||sid||','||serial#||chr(39)||';' from v$session where username='&a'; select 'spool off' from dual; spool off @kill_&a_sess_i1.sql spool chk_Rajtest_sess_i1.log select 'set feedback on' from dual; select sid, serial# from v$session where username='Rajtest'; spool off Rebuild index set feedback off set echo off set serverout off set pages 0 set lines 200  col name new_val dbname noprint select name from v$database; spool rebuild_idx_&&dbname\.sql prompt spool rebuild_idx_&&dbname select 'alter index '||owner||'.'||table_name||' rebuild tablespace '||tablespace_name||'_NEW;'  from dba_indexes  where tablespace_name not in ('SYSTEM', 'SYSAUX', 'UNDOTBS1',...

Snapshot Standby database and how to convert physical standby database to snapshot standby database (READ WRITE mode)

 Snapshot Standby database and how to convert physical standby database to snapshot standby database (READ WRITE mode) SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS'; Session altered. SQL> SELECT   a.thread#,  b. last_seq, a.applied_seq, a. last_app_timestamp, b.last_seq-a.applied_seq   ARC_DIFF FROM (SELECT  thread#, MAX(sequence#) applied_seq, MAX(next_time) last_app_timestamp FROM gv$archived_log WHERE applied = 'YES' GROUP BY thread#) a,           (SELECT  thread#, MAX (sequence#) last_seq FROM gv$archived_log GROUP BY thread#) b WHERE a.thread# = b.thread#;    THREAD#   LAST_SEQ APPLIED_SEQ LAST_APP_TIMESTAMP     ARC_DIFF ---------- ---------- ----------- -------------------- ----------          1         75          75 04-DEC-2019 11:09:55          0 ...