Skip to content

Instantly share code, notes, and snippets.

set verify off
set trimspool on
set lines 132
set pages 10000
set markup html on;
set linesize 300
col INSTANCE_NAME format a10
col HOST_NAME format a30
col JOB format 9999999999
col SCHEMA_USER format a30
--REPORT_SQL_MONITOR_LIST
SET LONG 1000000
SET LONGCHUNKSIZE 1000000
SET LINESIZE 1000
SET PAGESIZE 0
SET TRIM ON
SET TRIMSPOOL ON
SET ECHO OFF
SET FEEDBACK OFF
@dotmaik1
dotmaik1 / redologs: Show Redo Logs info.sql
Created October 6, 2016 16:52
Show Redo Logs information
set linesize 300
column REDOLOG_FILE_NAME format a50
SELECT
a.GROUP#,
a.THREAD#,
a.SEQUENCE#,
a.ARCHIVED,
a.STATUS,
b.MEMBER AS REDOLOG_FILE_NAME,
(a.BYTES/1024/1024) AS SIZE_MB
@dotmaik1
dotmaik1 / reports: AWR-ADDM-ASH hourly script.sh
Created October 6, 2016 16:50
AWR-ADDM-ASH hourly script
05 8-17 * * 1-5 /dbms/oracle/local/AMCMPRN1/etc/Scripts/awrreport_html_hourly.ksh AMCMPRN1 > /tmp/AWR_report_AMCMPRN1.out 2>&1
08 8-17 * * 1-5 /dbms/oracle/local/AMCMPRN1/etc/Scripts/addmreport_hourly.ksh AMCMPRN1 > /tmp/addm_report_AMCMPRN1.out 2>&1
05 8-17 * * 1-5 /dbms/oracle/monitor/bin/ashreport_html_hourly.ksh -sAMCMPRN1 -t60 > /tmp/AWR_report_AMCMPRN1.out 2>&1
AWR:
oracle@mwamdb3p[DUMMY] /home/oracle => cat /dbms/oracle/local/AMCMPRN1/etc/Scripts/awrreport_html_hourly.ksh
@dotmaik1
dotmaik1 / reports: Segment advisor per schema.sql
Created October 6, 2016 16:49
Segment advisor per schema
DECLARE
l_object_id NUMBER;
BEGIN
-- Create a segment advisor task for the PAPERLESS tablespace.
DBMS_ADVISOR.create_task (
advisor_name => 'Segment Advisor',
task_name => 'PAPERLESS_SEGMENT_ADVISOR',
task_desc => 'Segment Advisor For PAPERLESS');
DBMS_ADVISOR.create_object (
SET PAGESIZE 50000
SET FEEDBACK OFF
SET MARKUP HTML ON SPOOL ON
SET NUM 24
SPOOL PROD_PAPERLESS_SEGMENT_ADVISOR.xls
-- Display the findings.
SET LINESIZE 250
COLUMN task_name FORMAT A20
@dotmaik1
dotmaik1 / reports: SQL Details Active Report.sql
Created October 6, 2016 16:48
SQL Details Active Report
This report uses data from views that are licensed with the Diagnostics and Tuning Pack.
http://www.oracle.com/technetwork/database/manageability/sql-detail-099420.html
How do I generate a SQL Details Active Report?
From SQL*Plus, invoke the dbms_sqltune.report_sql_detail function and spool the output
@dotmaik1
dotmaik1 / restorepoints: Restore points.sql
Created October 6, 2016 16:45
admin operations for restore point - flashback operations
--Creating Normal and Guaranteed Restore Points
CREATE RESTORE POINT before_upgrade;
CREATE RESTORE POINT before_upgrade GUARANTEE FLASHBACK DATABASE;
--Listing Restore Points
@dotmaik1
dotmaik1 / rman: delete archived redo logs not needed to flash back to a guaranteed restore point.sql
Created October 6, 2016 16:42
delete archived redo logs not needed to flash back to a guaranteed restore point
select extract(day from (sysdate - min(trunc(time))) day to second) + 1
from v$restore_point
/
I loaded the result into an environment variable. (Many thanks to whoever posted the code for that on this site. Experts Exchange rocks!)
Then I used RMAN to delete the archivelogs like this:
delete archivelog all completed before 'SYSDATE - $RESTORE_POINT_AGE';
rman
@dotmaik1
dotmaik1 / rman: maniobra de delete de archives.sql
Last active October 6, 2016 16:43
Delete archives and update catalog to check for the free space at the FRA
rman target /
crosscheck archivelog all;
crosscheck backupset;
catalog recovery area;
delete expired archivelog all;