Tuesday 19 March 2019

RMAN session / rman longops


RMAN backup status, RMAN jobs, rman back list, Is rman running, rman session, rman process -- With time (RAC version) col "Sid Serial#" for a15 col "Logon time" for a20 col spid for a6 select b.sid||','||b.serial# as "Sid Serial#", a.inst_id, b.status, a.spid, to_char(b.logon_time, 'dd Mon yyyy, hh24:mi') as "Logon time", b.client_info from gv$process a, gv$session b where a.addr=b.paddr and a.inst_id = b.inst_id and lower(client_info) like '%rman%'; -- Basic and (Non-RAC) select b.sid, b.serial#, a.spid, b.client_info from v$process a, v$session b where a.addr=b.paddr and client_info like '%rman%';

Wednesday 13 March 2019

Is database standby

Quick check to see if the instance is standby or primary? SQL> select database_role from v$database; DATABASE_ROLE ---------------- PHYSICAL STANDBY SQL> select controlfile_type from V$database; CONTROL ------- STANDBY Useful sql select to_char(max(next_time),'dd Mon yyyy hh24:mi:ss') from v$archived_log where applied = 'YES'; TO_CHAR(MAX(NEXT_TIME),'DDMON ----------------------------- 05 Mar 2019 07:24:02 alter session set nls_date_format='dd Mon yyyy hh24:mi:ss'; select * from ( SELECT FIRST_TIME, NEXT_TIME, SEQUENCE# FROM V$ARCHIVED_LOG ORDER BY SEQUENCE# desc) where rownum < 6 order by SEQUENCE#; FIRST_TIME NEXT_TIME SEQUENCE# ----------------------------- ----------------------------- ---------- 05 Feb 2019 06:39:02 05 Feb 2019 06:54:02 213003 05 Feb 2019 06:54:02 05 Feb 2019 07:09:02 213004 05 Feb 2019 07:09:02 05 Feb 2019 07:24:02 213005 05 Feb 2019 07:24:02 05 Feb 2019 07:39:02 213006 05 Feb 2019 07:39:02 05 Feb 2019 07:54:02 213007

Tuesday 12 March 2019

Kill session

-- Current session alter system kill session '213,98643'; alter system kill session '777,56244,@1'; -- Kill session from another instance alter system kill session '66,64486,@2'; alter system kill session '66,64486' IMMEDIATE;

Wednesday 16 January 2019

Schema Last analysed | Stale Stats

-- Summary of stale select stale_stats, count(*) from user_tab_statistics group by stale_stats; STA COUNT(*) --- ---------- 414 NO 2582 YES 199 select TABLE_NAME, STALE_STATS from user_tab_statistics where stale_stats = 'YES';