prompt prompt Inspection Inspector: Xiaomaimiao ([blog:] [QQ:646634621] [:xiaomaimiaolhr] [OCP,OCM,]) prompt InspectionInspection Time:&_date_time prompt :v6.0.6 prompt :2020-01-01 18:18:18 prompt prompt [] prompt
prompt prompt
prompt
()Inspection Service Summary | |||||
---|---|---|---|---|---|
- | ,DG,OGG, Version,PSU,,,Database Attributes etc. | -- | - | - | Libraries | -
- | - | - | Default hidden system parameters should not be modified | -spfile | -Statistics Level | -
- | - | - | Tablespace Usage | -UndoTablespace Usage | -, | -
- | Control FileControl Files | -- | - | - | |
ASM | -ASM | -ASM | -ASM | -ASM | -- |
JOB | -- | jobError Message | -- | - | - |
()Inspection | |||||
---|---|---|---|---|---|
RMAN | -RMAN | -RMAN | -RMANAll BackupsRMANAll Backups | -RMANAll BackupsDetailsRMANAll BackupsDetails, | -Control File | -
spfile | -RMAN | -Flashback DatabaseFlashback Technologies | -- | - | |
- | Archived Log Configuration | -- | - | 7 | -- |
Log Group Size | -- | - | - | - | |
SGA | -SGA | -SGA | -SGA | -SGADynamic Components | -PGA TARGET | -
IO | -IO | -IO | -- | Sort Activity | -- |
SQL | -TOP10SQL | -TOP10SQL | -TOP10SQL | -TOP10SQL | -TOP10SQL | -
TOP10SQLSQL ordered by Version Count | -TOP10SQLshared memory,SQLlibrary cacheTOP SQL | -DISK_SORTSQL | -ASHSQL | -SQLRUNNING_11G | -|
SQLRUNNING_10G | -LASTIn SnapshotSQL | -LASTIn SnapshotSQLIn the most recent snapshot,SQL | -SQLgv$sql_monitor,10 | -SQLGV$SQL_MONITOR,SQL | -|
SQLSQL | -- | - | - | - | |
- | - | - | - | - | - |
DG | -DG | -DG | -DGProcesses of Primary and Standby | -standbyIncluding Primary and Standbystandby(SRL) | -- |
() | |||||
---|---|---|---|---|---|
Database Users | -Database Users | -DBA | -SYS | -- | - |
- | Failed Login Users (Past Week) | -PROFILE | -- | - | |
- | SYSTEM | -SYSTEM | -- | - | - |
- | - | - | DB | -- | - |
() | |||||
---|---|---|---|---|---|
- | Object Summary | -- | 10segments | -10segments | -LOB | -
- | 1/2 | -Undo Undo | -- | - | |
- | - | 10WTables Without Primary Key | -- | - | - |
- | 10GBTable exceeds10GB | -10Objects | -100 | -- | - |
- | - | - | Invalid Partition Index | -- | - |
- | 5 | -- | - | - | - |
1M | -33,3 | -3Index Height3 | -- | - | |
Degree of Parallelism | -Degree of Parallelism | -Degree of Parallelism | -- | - | - |
- | : 2000,10ora, | -- | - | (db_link) | -- |
- | cacheless than201000,20Too Small | -- | typetype | -Data Pump | -
() | |||||
---|---|---|---|---|---|
AWR | -AWR | -AWR | -- | AWRin the viewload profile | -- |
AWR | -- | - | - | - | |
ASH | -ASH | -ASH | -- | - | - |
ADDM | -ADDM | -- | - | - | - |
- | - | 1 | -- | - | - |
- | Session Overview | -() | -ACTIVE | -10 | -10 | -
- | CPU | -- | - | - | |
- | ViewLOCK | -View | -- | - | - |
Memory Usage | -- | PGATop Consuming Processes | -- | - | - |
- | OLAPOnline Analytical Processing - (OLAP) | -Networking | -- | - |
(6) Health Check Results | |||||
---|---|---|---|---|---|
- | ,, | -,, | -- | - | - |
prompt
prompt
-- +====================================================================================================================+ -- | -- | <<<<< Inspection Service Summary >>>>> | -- | | -- +====================================================================================================================+ host echo start...Inspection Service Summary. . prompt prompt
host echo " . . ." prompt prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - DATABASE OVERVIEW - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt
Inspection | &_reporttitle..html |
---|---|
Inspection | &_date_time_timezone |
Inspection | &_v_current_user |
Inspection | &_v_sessionid |
&_hostinfo | |
&_platform_name / &_platform_id | |
Database Name | &_dbname |
Global Database Name | &_global_name |
&_instance_name | |
&_instance_name_all | |
&_dbversion | |
ID(DBID) | &_dbid |
RACand itsNode Count | &_rac_database |
CDBand itsPDB | &_pdbs |
&_creation_date | |
&_startup_time |
&_log_mode | |
Flashback Database | &_FLASHBACK_ON |
&_characterset | |
&_blocksize | |
Force Logging | &_FORCE_LOGGING |
&_DB_ROLE | |
DG | &_DGINFO |
OGG | &_GGS_GGSUSER_ROLE |
db time zone | &_timezone |
&_recyclebin1 | |
(G) | &_TS_DELETE |
&_DATABASE_SIZE |
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN banner FORMAT a300 HEADING '' SELECT banner FROM v$version; prompt prompt ● PSU
CLEAR COLUMNS COMPUTES SET DEFINE OFF col action_time for a30 col action for a10 col namespace for a10 col version for a10 col bundle_series for a10 col comments for a30 SELECT d.con_id, to_char(d.action_time, 'YYYY-MM-DD HH24:MI:SS') action_time, d.action, d.namespace, d.id, --d.bundle_series, d.comments FROM CDB_REGISTRY_HISTORY d order by d.con_id, d.action_time; prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF col IS_PUBLIC for a10 SELECT * FROM gv$cluster_interconnects D; prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a75 HEADING '' ENTMAP OFF COLUMN instance_number_print FORMAT a75 HEADING '' ENTMAP OFF COLUMN thread_number_print HEADING '' ENTMAP OFF COLUMN host_name_print FORMAT a75 HEADING '' ENTMAP OFF COLUMN version HEADING '' ENTMAP OFF COLUMN START_TIME FORMAT a75 HEADING '' ENTMAP OFF COLUMN uptime HEADING '()' ENTMAP OFF COLUMN parallel FORMAT a75 HEADING 'RAC' ENTMAP OFF COLUMN instance_status FORMAT a75 HEADING '' ENTMAP OFF COLUMN database_status FORMAT a75 HEADING '' ENTMAP OFF COLUMN logins FORMAT a75 HEADING '' ENTMAP OFF COLUMN archiver FORMAT a75 HEADING '' ENTMAP OFF SELECT '
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN name FORMAT a125 HEADING ' DB_NAME ' ENTMAP OFF COLUMN dbid HEADING 'DB_ID' ENTMAP OFF COLUMN db_unique_name HEADING 'DB_Unique_Name' ENTMAP OFF COLUMN creation_date FORMAT a140 HEADING ' CREATION_DATE ' ENTMAP OFF COLUMN platform_name_print FORMAT a140 HEADING ' PLATFORM_NAME ' ENTMAP OFF COLUMN current_scn HEADING 'SCN' ENTMAP OFF COLUMN log_mode HEADING '' ENTMAP OFF COLUMN open_mode FORMAT a180 HEADING ' OPEN_MODE ' ENTMAP OFF COLUMN force_logging FORMAT a140 HEADING ' FORCE_LOGGING ' ENTMAP OFF COLUMN flashback_on HEADING 'Flashback?' ENTMAP OFF COLUMN controlfile_type HEADING 'Control File Type' ENTMAP OFF COLUMN SUPPLEMENTAL_LOG_DATA_MIN FORMAT a25 HEADING 'SUPPLEMENTAL|LOG_DATA_MIN' ENTMAP OFF COLUMN SUPPLEMENTAL_LOG_DATA_PK FORMAT a25 HEADING 'SUPPLEMENTAL|LOG_DATA_PK' ENTMAP OFF COLUMN SUPPLEMENTAL_LOG_DATA_MIN FORMAT a25 HEADING 'SUPPLEMENTAL|LOG_DATA_MIN' ENTMAP OFF COLUMN last_open_incarnation# FORMAT a50 HEADING 'LAST_OPEN|INCARNATION#' ENTMAP OFF COLUMN DATABASE_ROLE FORMAT a140 HEADING ' DATABASE_ROLE ' ENTMAP OFF SELECT d.INST_ID, '
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT a.CON_ID, a.name, a.OPEN_MODE, a.RESTRICTED, a.DBID, a.GUID, a.CREATE_SCN, --a.APPLICATION_ROOT, --a.APPLICATION_PDB, --a.APPLICATION_SEED, --a.APPLICATION_ROOT_CON_ID, --to_char(a.CREATION_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATION_TIME, to_char(a.OPEN_TIME, 'YYYY-MM-DD HH24:MI:SS') OPEN_TIME, round(a.TOTAL_SIZE/1024/1024) TOTAL_SIZE_M FROM v$containers a; /* SELECT a.con_id, a.name, a.open_mode, a.restricted, a.dbid, a.guid, to_char(a.OPEN_TIME,'YYYY-MM-DD HH24:MI:SS') OPEN_TIME, a.CREATE_SCN, a.TOTAL_SIZE FROM v$pdbs a; SELECT a.con_id, a.name, a.open_mode, a.restricted, a.dbid, a.guid, to_char(a.OPEN_TIME,'YYYY-MM-DD HH24:MI:SS') OPEN_TIME a.CREATE_SCN, a.CREATION_TIME, a.TOTAL_SIZE, a.LOCAL_UNDO FROM v$pdbs a; */ prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN end_interval_time FORMAT a160 HEADING ' End_Interval_Time ' ENTMAP OFF COLUMN begin_interval_time FORMAT a140 HEADING ' Begin_Interval_Time ' ENTMAP OFF COLUMN STARTUP_TIME FORMAT a160 HEADING ' STARTUP_TIME ' ENTMAP OFF COLUMN PLATFORM_NAME FORMAT a100 HEADING ' PLATFORM_NAME ' ENTMAP OFF SET DEFINE ON BEGIN_INTERVAL_TIME, END_INTERVAL_TIME, DB_NAME, DBID, INSTANCE_NAME, INSTANCE_NUMBER, STARTUP_TIME, RELEASE, RAC, HOST_NAME, PLATFORM_NAME, CPUS, CORES, SOCKETS, MEMORY_G, ELAPSED_TIME, DB_TIME TO_CHAR(S.BEGIN_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') BEGIN_INTERVAL_TIME, TO_CHAR(S.END_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') END_INTERVAL_TIME, DB_NAME, S.DBID, INSTANCE_NAME, S.INSTANCE_NUMBER, TO_CHAR(S.STARTUP_TIME, 'YYYY-MM-DD hh24:MI:SS') STARTUP_TIME, VERSION RELEASE, PARALLEL RAC, HOST_NAME, DI.PLATFORM_NAME, V.CPUS CPUS, V.CORES, V.SOCKETS, V.MEMORY MEMORY_G, ROUND(EXTRACT(DAY FROM S.END_INTERVAL_TIME - S.BEGIN_INTERVAL_TIME) * 1440 + EXTRACT(HOUR FROM S.END_INTERVAL_TIME - S.BEGIN_INTERVAL_TIME) * 60 + EXTRACT(MINUTE FROM S.END_INTERVAL_TIME - S.BEGIN_INTERVAL_TIME) + EXTRACT(SECOND FROM S.END_INTERVAL_TIME - S.BEGIN_INTERVAL_TIME) / 60, 2) ELAPSED_TIME, ROUND((E.VALUE - B.VALUE) / 1000000 / 60, 2) DB_TIME, DBID, INSTANCE_NUMBER, SUM(CPUS) CPUS, SUM(CORES) CORES, SUM(SOCKETS) SOCKETS, SUM(MEMORY) MEMORY O.DBID, O.INSTANCE_NUMBER, DECODE(O.STAT_NAME, 'NUM_CPUS', O.VALUE) CPUS, DECODE(O.STAT_NAME, 'NUM_CPU_CORES', O.VALUE) CORES, DECODE(O.STAT_NAME, 'NUM_CPU_SOCKETS', O.VALUE) SOCKETS, DECODE(O.STAT_NAME, 'PHYSICAL_MEMORY_BYTES', TRUNC(O.VALUE / 1024 / 1024 / 1024, 2)) MEMORY WHERE O.STAT_NAME IN ('NUM_CPUS', 'NUM_CPU_CORES', 'NUM_CPU_SOCKETS', 'PHYSICAL_MEMORY_BYTES')) S.INSTANCE_NUMBER = V.INSTANCE_NUMBER) ON (S.INSTANCE_NUMBER = DI.INSTANCE_NUMBER AND S.STARTUP_TIME = DI.STARTUP_TIME AND S.DBID = DI.DBID) E.INSTANCE_NUMBER = S.INSTANCE_NUMBER AND E.STAT_NAME = 'DB time') E.INSTANCE_NUMBER = B.INSTANCE_NUMBER)) WHERE DRANK <= 10 prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT D.CON_ID, D.PROPERTY_NAME, D.PROPERTY_VALUE, D.DESCRIPTION FROM cdb_properties D ORDER BY D.CON_ID; prompt
prompt NOTE: [] CLEAR COLUMNS COMPUTES SET DEFINE OFF prompt ● ts_datafile_physical_size_G,(temp) prompt ● ts_tempfile_physical_size_G prompt ● ts_datafile_used_size_G,,RMAN(as compressed) select A.CON_ID, A.ts_datafile_physical_size_G, B.ts_tempfile_physical_size_G, C.ts_datafile_used_size_G FROM (select A.CON_ID, round(sum(bytes) / 1024 / 1024 / 1024, 2) ts_datafile_physical_size_G from CDB_data_files A GROUP BY A.CON_ID) A, (select A.CON_ID, round(sum(bytes) / 1024 / 1024 / 1024, 2) ts_tempfile_physical_size_G from CDB_temp_files A GROUP BY A.CON_ID) B, (select A.CON_ID, round(sum(bytes) / 1024 / 1024 / 1024, 2) ts_datafile_used_size_G from CDB_segments A GROUP BY A.CON_ID) C WHERE A.CON_ID = B.CON_ID AND A.CON_ID = C.CON_ID ORDER BY con_id; --COLUMN sum3 FORMAT 999,999,999,999,999 HEADING 'dmp(G)' --COLUMN sum1 FORMAT 999,999,999,999,999 HEADING 'RMAN(G)' --COLUMN sum2 FORMAT 999,999,999,999,999 HEADING '(G)' --SELECT '
prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT sys_context('USERENV', 'ACTION') ACTION, sys_context('USERENV', 'AUTHENTICATED_IDENTITY') AUTHENTICATED_IDENTITY, --sys_context('USERENV', 'AUTHENTICATION_TYPE') AUTHENTICATION_TYPE, sys_context('USERENV', 'AUTHENTICATION_METHOD') AUTHENTICATION_METHOD, sys_context('USERENV', 'CURRENT_EDITION_NAME') CURRENT_EDITION_NAME, sys_context('USERENV', 'CURRENT_SCHEMA') CURRENT_SCHEMA, sys_context('USERENV', 'CURRENT_USER') CURRENT_USER, sys_context('USERENV', 'DATABASE_ROLE') DATABASE_ROLE, sys_context('USERENV', 'DB_NAME') DB_NAME, sys_context('USERENV', 'DB_UNIQUE_NAME') DB_UNIQUE_NAME, sys_context('USERENV', 'HOST') HOST, -- userenv('terminal') sys_context('USERENV', 'IDENTIFICATION_TYPE') IDENTIFICATION_TYPE, sys_context('USERENV', 'INSTANCE') INSTANCE, --userenv('INSTANCE') sys_context('USERENV', 'INSTANCE_NAME') INSTANCE_NAME, sys_context('USERENV', 'IP_ADDRESS') IP_ADDRESS, --ora_client_ip_address sys_context('USERENV', 'ISDBA') ISDBA, --userenv('ISDBA') sys_context('USERENV', 'LANG') LANG, --userenv('LANG') sys_context('USERENV', 'LANGUAGE') LANGUAGE, --userenv('LANGUAGE'), sys_context('USERENV', 'MODULE') MODULE, sys_context('USERENV', 'NETWORK_PROTOCOL') NETWORK_PROTOCOL, sys_context('USERENV', 'NLS_CALENDAR') NLS_CALENDAR, sys_context('USERENV', 'NLS_CURRENCY') NLS_CURRENCY, sys_context('USERENV', 'NLS_DATE_FORMAT') NLS_DATE_FORMAT, sys_context('USERENV', 'NLS_DATE_LANGUAGE') NLS_DATE_LANGUAGE, sys_context('USERENV', 'NLS_SORT') NLS_SORT, sys_context('USERENV', 'NLS_TERRITORY') NLS_TERRITORY, sys_context('USERENV', 'OS_USER') OS_USER, sys_context('USERENV', 'SERVER_HOST') SERVER_HOST, sys_context('USERENV', 'SERVICE_NAME') SERVICE_NAME, sys_context('USERENV', 'SESSION_EDITION_ID') SESSION_EDITION_ID, sys_context('USERENV', 'SESSION_EDITION_NAME') SESSION_EDITION_NAME, sys_context('USERENV', 'SESSION_USER') SESSION_USER, --ora_login_user sys_context('USERENV', 'SESSIONID') SESSIONID, -- userenv('SESSIONID') , v$session.audsid sys_context('USERENV', 'SID') SID, sys_context('USERENV', 'TERMINAL') TERMINAL --userenv('terminal') FROM dual; prompt
prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN RESOURCE_NAME FORMAT a75 HEADING '' ENTMAP OFF COLUMN CURRENT_UTILIZATION FORMAT 999,999,999,999,999 HEADING '' ENTMAP OFF COLUMN MAX_UTILIZATION FORMAT 999,999,999,999,999 HEADING '' ENTMAP OFF COLUMN INITIAL_ALLOCATION FORMAT 999,999,999,999,999 HEADING '' ENTMAP OFF COLUMN LIMIT_VALUE FORMAT 999,999,999,999,999 HEADING 'Limit Value' ENTMAP OFF SELECT a.con_id, a.inst_id, a.resource_name, a.current_utilization, a.max_utilization, a.initial_allocation, a.limit_value FROM gv$resource_limit a order by a.con_id, a.inst_id, a.resource_name; prompt
-------------------------------------------------------------------- prompt prompt
-- +----------------------------------------------------------------------------+ -- | - OPTIONS - | -- +----------------------------------------------------------------------------+ prompt prompt ● Options
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN parameter HEADING 'Option Name' ENTMAP OFF COLUMN value HEADING 'Installed?' ENTMAP OFF SELECT a.inst_id, DECODE(value, 'FALSE', '' || parameter || '', '' || parameter || '') parameter, DECODE(value, 'FALSE', '
prompt -- +----------------------------------------------------------------------------+ -- | - DATABASE REGISTRY - | -- +----------------------------------------------------------------------------+ prompt prompt ● Database Registry
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN comp_id FORMAT a75 HEADING 'Component ID' ENTMAP OFF COLUMN comp_name FORMAT a75 HEADING 'Component Name' ENTMAP OFF COLUMN version HEADING 'Version' ENTMAP OFF COLUMN status FORMAT a75 HEADING 'Status' ENTMAP OFF COLUMN modified FORMAT a75 HEADING 'Modified' ENTMAP OFF COLUMN control HEADING 'Control' ENTMAP OFF COLUMN schema HEADING 'Schema' ENTMAP OFF COLUMN procedure HEADING 'Procedure' ENTMAP OFF SELECT d.CON_ID, '' || comp_id || '' comp_id, '
-- +----------------------------------------------------------------------------+ -- | - FEATURE USAGE STATISTICS - | -- +----------------------------------------------------------------------------+ prompt prompt ● Feature Usage Statistics[Next Item]
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN feature_name FORMAT a115 HEADING 'Feature|Name' COLUMN version FORMAT a75 HEADING 'Version' COLUMN detected_usages FORMAT a75 HEADING 'Detected|Usages' COLUMN total_samples FORMAT a75 HEADING 'Total|Samples' COLUMN currently_used FORMAT a60 HEADING 'Currently|Used' COLUMN first_usage_date FORMAT a95 HEADING 'First Usage|Date' COLUMN last_usage_date FORMAT a95 HEADING 'Last Usage|Date' COLUMN last_sample_date FORMAT a95 HEADING 'Last Sample|Date' COLUMN next_sample_date FORMAT a95 HEADING 'Next Sample|Date' SELECT d.CON_ID, '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - HIGH WATER MARK STATISTICS - | -- +----------------------------------------------------------------------------+ prompt prompt ● High Water Mark Statistics
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN statistic_name FORMAT a115 HEADING 'Statistic Name' COLUMN version FORMAT a62 HEADING 'Version' COLUMN highwater FORMAT 9,999,999,999,999,999 HEADING 'Highwater' COLUMN last_value FORMAT 9,999,999,999,999,999 HEADING 'Last Value' COLUMN description FORMAT a120 HEADING 'Description' SELECT d.CON_ID, '
-- +----------------------------------------------------------------------------+ -- | - LIBRARIES - | -- +----------------------------------------------------------------------------+ prompt prompt Libraries[Next Item]
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN library_name FORMAT a75 HEADING 'Library Name' ENTMAP OFF COLUMN file_spec HEADING 'File Spec' ENTMAP OFF COLUMN dynamic FORMAT a75 HEADING 'Dynamic?' ENTMAP OFF COLUMN status FORMAT a75 HEADING 'Status' ENTMAP OFF SELECT D.CON_ID, '
-- +----------------------------------------------------------------------------+ -- | - INITIALIZATION PARAMETERS - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt
prompt prompt [Next Item]
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN spfile HEADING 'SPFILE Usage' SELECT case WHEN d.VALUE IS NOT NULL then 'This database ' || 'IS' || ' using an SPFILE.' else 'This database ' || 'IS NOT' || ' using an SPFILE.' end AS sspfile FROM v$parameter d WHERE d.NAME = 'spfile'; COLUMN pname FORMAT a75 HEADING 'Parameter Name' ENTMAP OFF COLUMN instance_name_print FORMAT a45 HEADING 'Instance_Name' ENTMAP OFF COLUMN value FORMAT a75 HEADING 'Value' ENTMAP OFF COLUMN isdefault FORMAT a75 HEADING 'Is Default?' ENTMAP OFF COLUMN issys_modifiable FORMAT a75 HEADING 'Is Dynamic?' ENTMAP OFF COLUMN ISDEPRECATED FORMAT a75 HEADING 'ISDEPRECATED' ENTMAP OFF COLUMN DESCRIPTION FORMAT a200 HEADING 'DESCRIPTION ' ENTMAP OFF SELECT P.CON_ID,DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.name, 0, 512) || '', '' || SUBSTR(p.name, 0, 512) || '') pname, DECODE(p.isdefault, 'FALSE', '' || i.instance_name || '', i.instance_name) instance_name_print, DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.value, 0, 512) || '', SUBSTR(p.value, 0, 512)) value, p.DISPLAY_VALUE, DECODE(p.isdefault, 'FALSE', '
prompt PDB CDB PDB_SPFILE$ con_id difference, therefore, PDB PDB_SPFILE$ ,V$SYSTEM_PARAMETERFetch CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN pname FORMAT a75 HEADING 'Parameter Name' ENTMAP OFF COLUMN instance_name_print FORMAT a45 HEADING 'Instance_Name' ENTMAP OFF COLUMN value FORMAT a75 HEADING 'Value' ENTMAP OFF COLUMN isdefault FORMAT a75 HEADING 'Is Default?' ENTMAP OFF COLUMN issys_modifiable FORMAT a75 HEADING 'Is Dynamic?' ENTMAP OFF COLUMN ISDEPRECATED FORMAT a75 HEADING 'ISDEPRECATED' ENTMAP OFF COLUMN DESCRIPTION FORMAT a200 HEADING 'DESCRIPTION ' ENTMAP OFF SET DEFINE ON select a.pdb_uid , b.NAME , a.name , a.value$ from pdb_spfile$ a , v$pdbs b where a.pdb_uid = b.CON_UID order by b.NAME ; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN pname FORMAT a75 HEADING '' ENTMAP OFF COLUMN instance_name_print FORMAT a45 HEADING '' ENTMAP OFF COLUMN value FORMAT a75 HEADING 'Parameter Value' ENTMAP OFF SELECT P.CON_ID,DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.name, 0, 512) || '', '' || SUBSTR(p.name, 0, 512) || '') pname, DECODE(p.isdefault, 'FALSE', '' || i.instance_name || '', i.instance_name) instance_name_print, DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.value, 0, 512) || '', SUBSTR(p.value, 0, 512)) value FROM gv$parameter p, gv$instance i WHERE p.inst_id = i.inst_id AND p.name in ('shared_pool_size','open_cursors','processes','job_queue_processes','sga_max_size','log_archive_dest_1', 'sessions','spfile','cpu_count','sga_target','db_cache_size','shared_pool_size','large_pool_size','java_pool_size','log_buffer','pga_aggregate_target','sort_area_size','db_block_size','optimizer_mode','cursor_sharing','open_cursors','optimizer_index_cost_adj','optimizer_index_caching','db_file_multiblock_read_count','hash_join_enabled','thread','instance_number','instance_name','local_listener','compatible','commit_point_strength','dblink_encrypt_login','distributed_lock_timeout','distributed_recovery_connection_hold_time','distributed_transactions','global_names','job_queue_interval','job_queue_processes','max_transaction_branches','open_links','open_links_per_instance','parallel_automatic_tuning','parallel_max_servers','parallel_min_servers','parallel_server_idle_time','processes','remote_dependencies_mode','replication_dependency_tracking','shared_pool_size','utl_file_dir','db_create_file_dest') ORDER BY p.name, i.instance_name; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN pname FORMAT a75 HEADING 'Parameter Name' ENTMAP OFF COLUMN instance_name_print FORMAT a45 HEADING 'Instance_Name' ENTMAP OFF COLUMN value FORMAT a75 HEADING 'Value' ENTMAP OFF COLUMN isdefault FORMAT a75 HEADING 'Is Default?' ENTMAP OFF COLUMN issys_modifiable FORMAT a75 HEADING 'Is Dynamic?' ENTMAP OFF COLUMN ISDEPRECATED FORMAT a75 HEADING 'ISDEPRECATED' ENTMAP OFF COLUMN DESCRIPTION FORMAT a200 HEADING 'DESCRIPTION ' ENTMAP OFF SET DEFINE ON SELECT P.CON_ID, DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.name, 0, 512) || '', '' || SUBSTR(p.name, 0, 512) || '') pname, DECODE(p.isdefault, 'FALSE', '' || i.instance_name || '', i.instance_name) instance_name_print, DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.value, 0, 512) || '', SUBSTR(p.value, 0, 512)) value, p.DISPLAY_VALUE, DECODE(p.isdefault, 'FALSE', '
-- +----------------------------------------------------------------------------+ -- | - STATISTICS LEVEL - | -- +----------------------------------------------------------------------------+ prompt prompt Statistics Level
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a20 HEADING 'Instance_Name' ENTMAP OFF COLUMN statistics_name FORMAT a50 HEADING 'Statistics Name' ENTMAP OFF COLUMN session_status FORMAT a20 HEADING 'Session Status' ENTMAP OFF COLUMN system_status FORMAT a20 HEADING 'System Status' ENTMAP OFF COLUMN activation_level FORMAT a20 HEADING 'Activation Level' ENTMAP OFF COLUMN statistics_view_name FORMAT a100 HEADING ' Statistics View Name ' ENTMAP OFF COLUMN session_settable FORMAT a20 HEADING 'Session Settable?' ENTMAP OFF SET DEFINE ON SELECT '
-------------------------------------------------------------------- host echo " . . ." prompt prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN status HEADING '' ENTMAP OFF COLUMN name HEADING '' ENTMAP OFF COLUMN type FORMAT a12 HEADING '' ENTMAP OFF COLUMN extent_mgt FORMAT a12 HEADING '' ENTMAP OFF COLUMN segment_mgt FORMAT a12 HEADING 'Segment Management Type' ENTMAP OFF COLUMN ts_size FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN free FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN used FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN pct_used HEADING 'Pct. Used' ENTMAP OFF COLUMN BIGFILE FORMAT a10 HEADING 'BIGFILE' ENTMAP OFF COMPUTE SUM label 'Total:' OF ts_size used free ON report SELECT CON_ID, PDBNAME, TS#, TS_NAME, TS_SIZE_M, FREE_SIZE_M, USED_SIZE_M, USED_PER, MAX_SIZE_G, USED_PER_MAX, BLOCK_SIZE, LOGGING, TS_DF_COUNT FROM (WITH wt1 AS (SELECT ts.CON_ID, (SELECT np.NAME FROM V$CONTAINERS np WHERE np.CON_ID = tS.con_id) PDBNAME, (SELECT A.TS# FROM V$TABLESPACE A WHERE A.NAME = UPPER(tS.TABLESPACE_NAME) AND a.CON_ID = tS.con_id) TS#, ts.TABLESPACE_NAME, df.all_bytes, decode(df.TYPE, 'D', nvl(fs.FREESIZ, 0), 'T', df.all_bytes - nvl(fs.FREESIZ, 0)) FREESIZ, df.MAXSIZ, ts.BLOCK_SIZE, ts.LOGGING, ts.FORCE_LOGGING, ts.CONTENTS, ts.EXTENT_MANAGEMENT, ts.SEGMENT_SPACE_MANAGEMENT, ts.RETENTION, ts.DEF_TAB_COMPRESSION, df.ts_df_count FROM cdb_tablespaces ts, (SELECT d.CON_ID, 'D' TYPE, TABLESPACE_NAME, COUNT(*) ts_df_count, SUM(BYTES) all_bytes, SUM(decode(MAXBYTES, 0, BYTES, MAXBYTES)) MAXSIZ FROM cdb_data_files d GROUP BY d.CON_ID, TABLESPACE_NAME UNION ALL SELECT d.CON_ID, 'T', TABLESPACE_NAME, COUNT(*) ts_df_count, SUM(BYTES) all_bytes, SUM(decode(MAXBYTES, 0, BYTES, MAXBYTES)) FROM cdb_temp_files d GROUP BY d.CON_ID, TABLESPACE_NAME) df, (SELECT d.CON_ID, TABLESPACE_NAME, SUM(BYTES) FREESIZ FROM cdb_free_space d GROUP BY d.CON_ID, TABLESPACE_NAME UNION ALL SELECT d.CON_ID, tablespace_name, SUM(d.BLOCK_SIZE * a.BLOCKS) bytes FROM gv$sort_usage a, cdb_tablespaces d WHERE a.tablespace = d.tablespace_name AND a.CON_ID = d.CON_ID GROUP BY d.CON_ID, tablespace_name) fs WHERE ts.TABLESPACE_NAME = df.TABLESPACE_NAME AND ts.CON_ID = df.CON_ID AND ts.TABLESPACE_NAME = fs.TABLESPACE_NAME(+) AND ts.CON_ID = fs.CON_ID(+)) SELECT T.CON_ID, (CASE WHEN T.PDBNAME = LAG(T.PDBNAME, 1) OVER(PARTITION BY T.PDBNAME ORDER BY TS#) THEN NULL ELSE T.PDBNAME END) PDBNAME, TS#, t.TABLESPACE_NAME TS_Name, round(t.all_bytes / 1024 / 1024) ts_size_M, round(t.freesiz / 1024 / 1024) Free_Size_M, round((t.all_bytes - t.FREESIZ) / 1024 / 1024) Used_Size_M, round((t.all_bytes - t.FREESIZ) * 100 / t.all_bytes, 3) Used_per, round(MAXSIZ / 1024 / 1024 / 1024, 3) MAX_Size_g, round(decode(MAXSIZ, 0, to_number(NULL), (t.all_bytes - FREESIZ)) * 100 / MAXSIZ, 3) USED_per_MAX, round(t.BLOCK_SIZE) BLOCK_SIZE, t.LOGGING, t.ts_df_count FROM wt1 t UNION ALL SELECT DISTINCT T.CON_ID, '' PDBNAME, to_number('') TS#, 'ALL TS:' TS_Name, round(SUM(t.all_bytes) / 1024 / 1024, 3) ts_size_M, round(SUM(t.freesiz) / 1024 / 1024) Free_Size_m, round(SUM(t.all_bytes - t.FREESIZ) / 1024 / 1024) Used_Size_M, round(SUM(t.all_bytes - t.FREESIZ) * 100 / SUM(t.all_bytes), 3) Used_per, round(SUM(MAXSIZ) / 1024 / 1024 / 1024) MAX_Size, to_number('') "USED,% of MAX Size", to_number('') BLOCK_SIZE, '' LOGGING, to_number('') ts_df_count FROM wt1 t GROUP BY rollup(CON_ID,PDBNAME) ) ORDER BY CON_ID,TS# ; prompt ● SYSAUXDetails
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT D.CON_ID, OCCUPANT_NAME, OCCUPANT_DESC, SCHEMA_NAME, MOVE_PROCEDURE, MOVE_PROCEDURE_DESC, SPACE_USAGE_KBYTES SPACE_USAGE_KB, ROUND(SPACE_USAGE_KBYTES / 1024 / 1024, 2) SPACE_USAGE_G FROM V$SYSAUX_OCCUPANTS D ORDER BY D.CON_ID, D.SPACE_USAGE_KBYTES DESC; prompt
prompt NOTE: cdb_hist_seg_statcdb_hist_seg_stat_obj CLEAR COLUMNS COMPUTES SET DEFINE OFF a.con_id, e.name pdbname, c.tablespace_name ts_name, to_char(to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss'), 'yyyy-mm-dd hh24:mi') rtime, round(a.tablespace_size * c.block_size / 1024 / 1024, 2) ts_size_mb, round(a.tablespace_usedsize * c.block_size / 1024 / 1024, 2) ts_used_mb, round((a.tablespace_size - a.tablespace_usedsize) * c.block_size / 1024 / 1024, 2) ts_free_mb, round(a.tablespace_usedsize / a.tablespace_size * 100, 2) pct_used FROM cdb_hist_tbspc_space_usage a, (SELECT tablespace_id, nb.con_id, substr(rtime, 1, 10) rtime, FROM cdb_hist_tbspc_space_usage nb group by tablespace_id, nb.con_id,substr(rtime, 1, 10)) b, cdb_tablespaces c, v$tablespace d, V$CONTAINERS e and a.tablespace_id = b.tablespace_id and a.con_id=b.con_id and a.con_id=c.con_id and a.con_id=d.con_id and a.con_id=e.con_id and a.tablespace_id=d.TS# and d.NAME=c.tablespace_name and to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') >=sysdate-30 order by a.CON_ID,a.tablespace_id,to_date(a.rtime, 'mm/dd/yyyy hh24:mi:ss') desc; prompt
prompt ● Flashback Database
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT NAME, round(space_limit / 1024 / 1024 / 1024, 3) "LIMIT_GB", round(space_used / 1024 / 1024 / 1024, 3) "USED_GB", round(space_used / space_limit * 100, 3) "USED%", round(space_reclaimable / 1024 / 1024 / 1024, 3) "RECLAIM_GB", number_of_files FROM v$recovery_file_dest v WHERE v.SPACE_LIMIT<>0; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF ---- BREAK ON report --COMPUTE SUM label 'Total:' OF USED_GB percent_space_used percent_space_reclaimable RECLAIM_GB number_of_files ON report SELECT nvl(frau.file_type,'Total:') file_type, sum(round(frau.percent_space_used / 100 * rfd.space_limit / 1024 / 1024 / 1024,3)) USED_GB, sum(frau.percent_space_used) percent_space_used, sum(frau.percent_space_reclaimable) percent_space_reclaimable, sum(round(frau.percent_space_reclaimable / 100 * rfd.space_limit / 1024 / 1024 / 1024,3)) RECLAIM_GB, sum(frau.number_of_files) number_of_files FROM v$flash_recovery_area_usage frau, v$recovery_file_dest rfd GROUP BY ROLLUP(file_type) ; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT D.CON_ID, d.tablespace_name "Name", TO_CHAR(NVL(a.bytes / 1024 / 1024, 0), '99,999,990.900') "Size (M)", TO_CHAR(NVL(t.hwm, 0) / 1024 / 1024, '99999999.999') "HWM (M)", TO_CHAR(NVL(t.hwm / a.bytes * 100, 0), '990.00') "HWM % ", TO_CHAR(NVL(t.bytes / 1024 / 1024, 0), '99999999.999') "Using (M)", TO_CHAR(NVL(t.bytes / a.bytes * 100, 0), '990.00') "Using %" FROM CDB_tablespaces d, (SELECT A.CON_ID, tablespace_name, sum(bytes) bytes FROM CDB_temp_files A GROUP BY A.CON_ID, tablespace_name) a, (SELECT A.CON_ID, tablespace_name, sum(bytes_cached) hwm, sum(bytes_used) bytes FROM v$temp_extent_pool A GROUP BY A.CON_ID, tablespace_name) t WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = t.tablespace_name(+) AND D.CON_ID=A.CON_ID(+) AND D.CON_ID=T.CON_ID(+) AND d.extent_management = 'LOCAL' AND d.contents = 'TEMPORARY'; prompt
prompt prompt UndoTablespace Usage
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT r.name , rssize/1024/1024/1024 "RSSize(G)", s.sid, s.serial#, s.username , s.status, s.sql_hash_value, s.SQL_ADDRESS, s.MACHINE, s.MODULE, substr(s.program, 1, 78) , r.usn, hwmsize/1024/1024/1024,shrinks ,xacts FROM sys.v_$session s,sys.v_$transaction t,sys.v_$rollname r, v$rollstat rs WHERE t.addr = s.taddr AND t.xidusn = r.usn AND r.usn=rs.USN ORDER BY rssize desc; prompt
prompt NOTE: UndoTemp prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN autoextensible FORMAT a100 HEADING 'autoextensible' ENTMAP OFF COLUMN online_status FORMAT a15 HEADING 'online_status' ENTMAP OFF SELECT t.con_id, t.FILE_ID, t.file_name, t.tablespace_name, (t.bytes) Undo_TS_SIZE, (DECODE(MAXBYTES, 0, BYTES, MAXBYTES)) MAXSIZE, DECODE(t.autoextensible, 'YES', '
COLUMN autoextensible FORMAT a100 HEADING 'autoextensible' ENTMAP OFF SELECT t.CON_ID, t.FILE_ID, t.file_name, t.TABLESPACE_NAME, (t.bytes) Temp_TS_SIZE, (DECODE(MAXBYTES, 0, BYTES, MAXBYTES)) MAXSIZE, t.status, DECODE(t.autoextensible, 'YES', '
prompt
-- +============================================================================+
-- | |
-- | <<<<< STORAGE >>>>> |
-- | |
-- +============================================================================+
-- +----------------------------------------------------------------------------+
-- | - DATA FILES - |
-- +----------------------------------------------------------------------------+
prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN AUTOEXTENSIBLE format a15 HEADING 'AUTOEXTENSIBLE' ENTMAP OFF COLUMN CREATION_TIME FORMAT a140 HEADING ' CREATION_TIME ' ENTMAP OFF COLUMN MAXBYTES FORMAT 999,999,999,999,999 HEADING 'MAXBYTES' ENTMAP OFF SET DEFINE ON SELECT FILE_ID, CON_ID, (CASE WHEN T.PDBNAME = LAG(T.PDBNAME, 1) OVER(PARTITION BY T.PDBNAME ORDER BY TS#) THEN NULL ELSE T.PDBNAME END) PDBNAME, TS#, TABLESPACE_NAME, TS_SIZE_M, FILE_NAME, FILE_SIZE_M, FILE_MAX_SIZE_G, AUTOEXTENSIBLE, INCREMENT_M, AUTOEXTEND_RATIO, CREATION_TIME, INCREMENT_BY_BLOCK, BYTES, BLOCKS, MAXBYTES, MAXBLOCKS, USER_BYTES, USER_BLOCKS FROM (SELECT D.FILE_ID, D.CON_ID, (SELECT NP.NAME FROM V$CONTAINERS NP WHERE NP.CON_ID = D.CON_ID) PDBNAME, (SELECT A.TS# FROM V$TABLESPACE A WHERE A.NAME = UPPER(D.TABLESPACE_NAME) AND A.CON_ID = D.CON_ID) TS#, D.TABLESPACE_NAME, (SELECT ROUND(SUM(NB.BYTES) / 1024 / 1024, 2) FROM CDB_DATA_FILES NB WHERE NB.TABLESPACE_NAME = D.TABLESPACE_NAME AND NB.CON_ID = D.CON_ID) TS_SIZE_M, D.FILE_NAME, ROUND(D.BYTES / 1024 / 1024, 2) FILE_SIZE_M, ROUND(D.MAXBYTES / 1024 / 1024 / 1024, 2) FILE_MAX_SIZE_G, D.AUTOEXTENSIBLE, ROUND(D.INCREMENT_BY * 8 * 1024 / 1024 / 1024, 2) INCREMENT_M, ROUND(D.BYTES * 100 / DECODE(D.MAXBYTES, 0, BYTES, D.MAXBYTES), 2) AUTOEXTEND_RATIO, (SELECT B.CREATION_TIME FROM SYS.V_$DATAFILE B WHERE B.FILE# = D.FILE_ID AND B.CON_ID = D.CON_ID) CREATION_TIME, D.INCREMENT_BY INCREMENT_BY_BLOCK, D.BYTES, D.BLOCKS, D.MAXBYTES, D.MAXBLOCKS, D.USER_BYTES, D.USER_BLOCKS FROM CDB_DATA_FILES D UNION ALL SELECT D.FILE_ID, D.CON_ID, (SELECT NP.NAME FROM V$CONTAINERS NP WHERE NP.CON_ID = D.CON_ID) PDBNAME, (SELECT A.TS# FROM V$TABLESPACE A WHERE A.NAME = UPPER(D.TABLESPACE_NAME) AND A.CON_ID = D.CON_ID) TS#, D.TABLESPACE_NAME, (SELECT ROUND(SUM(NB.BYTES) / 1024 / 1024, 2) FROM V$TEMPFILE NB WHERE NB.NAME = D.FILE_NAME AND NB.CON_ID = D.CON_ID) TS_SIZE, D.FILE_NAME, ROUND(D.BYTES / 1024 / 1024, 2) FILE_SIZE_M, ROUND(D.MAXBYTES / 1024 / 1024 / 1024, 2) FILE_MAX_SIZE_G, D.AUTOEXTENSIBLE, ROUND(D.INCREMENT_BY * 8 * 1024 / 1024 / 1024, 2) INCREMENT_M, ROUND(D.BYTES * 100 / DECODE(D.MAXBYTES, 0, BYTES, D.MAXBYTES), 2) AUTOEXTEND_RATIO, (SELECT B.CREATION_TIME FROM SYS.V_$DATAFILE B WHERE B.FILE# = D.FILE_ID AND B.CON_ID = D.CON_ID) CREATION_TIME, D.INCREMENT_BY INCREMENT_BY_BLOCK, D.BYTES, D.BLOCKS, D.MAXBYTES, D.MAXBLOCKS, D.USER_BYTES, D.USER_BLOCKS FROM CDB_TEMP_FILES D) T ORDER BY CON_ID,TS#,FILE_ID; prompt
------------------------------------------------------------------------------------------------------------------------------------------------ prompt prompt ● Control File(Control Files)
-- +----------------------------------------------------------------------------+ -- | - CONTROL FILES - | -- +----------------------------------------------------------------------------+ prompt prompt ● Control Files
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN name HEADING 'Controlfile Name' ENTMAP OFF COLUMN status FORMAT a75 HEADING 'Status' ENTMAP OFF COLUMN file_size FORMAT a75 HEADING 'File Size' ENTMAP OFF SELECT C.NAME NAME, DECODE(C.STATUS, NULL, '
-- +----------------------------------------------------------------------------+ -- | - CONTROL FILE RECORDS - | -- +----------------------------------------------------------------------------+ prompt prompt Control File Records
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN type FORMAT a95 HEADING 'Record Section Type' ENTMAP OFF COLUMN record_size FORMAT 999,999 HEADING 'Record Size|(in bytes)' ENTMAP OFF COLUMN records_total FORMAT 999,999 HEADING 'Records Allocated' ENTMAP OFF COLUMN bytes_alloc FORMAT 999,999,999 HEADING 'Bytes Allocated' ENTMAP OFF COLUMN records_used FORMAT 999,999 HEADING 'Records Used' ENTMAP OFF COLUMN bytes_used FORMAT 999,999,999 HEADING 'Bytes Used' ENTMAP OFF COLUMN pct_used FORMAT B999 HEADING '% Used' ENTMAP OFF COLUMN first_index HEADING 'First Index' ENTMAP OFF COLUMN last_index HEADING 'Last Index' ENTMAP OFF COLUMN last_recid HEADING 'Last RecID' ENTMAP OFF COMPUTE sum LABEL 'Total: ' of record_size records_total bytes_alloc records_used bytes_used ON report COMPUTE avg LABEL 'Average: ' of pct_used ON report SELECT '
-------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------- host echo " ASM. . ." prompt prompt ASM
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF --COMPUTE SUM label 'Total:' OF TOTAL_MB FREE_MB ON report SELECT a.con_id, a.inst_id , a.GROUP_NUMBER, a.DISK_NUMBER, a.NAME, a.path, a.STATE, a.MOUNT_STATUS, a.TOTAL_MB, a.FREE_MB, a.CREATE_DATE, a.MOUNT_DATE, a.LIBRARY --, --a.OS_MB FROM gV$ASM_DISK a ORDER BY a.con_id,a.inst_id, a.GROUP_NUMBER, a.DISK_NUMBER; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF --COMPUTE SUM label 'Total:' OF TOTAL_MB FREE_MB ON report SELECT di.CON_ID, di.inst_id, di.GROUP_NUMBER, di.NAME, di.BLOCK_SIZE, di.STATE, di.TYPE, di.TOTAL_MB, di.FREE_MB, di.COMPATIBILITY, --di.VOTING_FILES, di.OFFLINE_DISKS FROM gv$asm_diskgroup di ORDER BY di.con_id, di.inst_id, di.GROUP_NUMBER; prompt
prompt prompt ASM[Next Item]
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM gv$ASM_ATTRIBUTE d WHERE d.NAME NOT LIKE 'template.%' ORDER BY d.con_id,d.inst_id, d.GROUP_NUMBER,d.NAME ; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM gv$asm_client; prompt
------------------------------------------------------------------------------------------------------------------------------------------------ host echo " JOB. . ." prompt prompt JOB
prompt
prompt ● cdb_jobs
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN job_id FORMAT a75 HEADING 'ID' ENTMAP OFF COLUMN username FORMAT a75 HEADING '' ENTMAP OFF COLUMN what FORMAT a100 HEADING '' ENTMAP OFF COLUMN next_date FORMAT a140 HEADING ' ' ENTMAP OFF COLUMN interval FORMAT a100 HEADING ' ' ENTMAP OFF COLUMN last_date FORMAT a140 HEADING ' ' ENTMAP OFF COLUMN failures FORMAT a75 HEADING 'Failure Count' ENTMAP OFF COLUMN broken FORMAT a75 HEADING '?' ENTMAP OFF SET DEFINE ON SELECT d.CON_ID, DECODE(broken, 'Y', '
') || '
') || '
') || '
') || '
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN is_running FORMAT a10 HEADING 'is_running' ENTMAP OFF COLUMN REPEAT_INTERVAL FORMAT a140 HEADING ' REPEAT_INTERVAL ' ENTMAP OFF COLUMN start_date FORMAT a140 HEADING ' START_DATE ' ENTMAP OFF COLUMN end_date FORMAT a140 HEADING ' END_DATE ' ENTMAP OFF COLUMN NEXT_RUN_DATE FORMAT a140 HEADING ' NEXT_RUN_DATE ' ENTMAP OFF COLUMN last_start_date FORMAT a140 HEADING ' LAST_START_DATE ' ENTMAP OFF COLUMN LAST_RUN_DURATION FORMAT a140 HEADING ' LAST_RUN_DURATION ' ENTMAP OFF COLUMN comments FORMAT a180 HEADING ' job_comments ' ENTMAP OFF SET DEFINE ON SELECT j.CON_ID, j.JOB_CREATOR, j.OWNER, j.job_name, j.state job_STATE, DECODE(J.STATE, 'RUNNING', 'Y', 'N') is_running, j.job_type, j.job_action, j.JOB_STYLE, j.PROGRAM_OWNER, j.PROGRAM_NAME, j.schedule_type, j.repeat_interval, TO_CHAR(j.start_date, 'YYYY-MM-DD HH24:mi:ss') start_date, TO_CHAR(j.end_date, 'YYYY-MM-DD HH24:mi:ss') end_date, TO_CHAR(J.NEXT_RUN_DATE, 'YYYY-MM-DD HH24:mi:ss') NEXT_RUN_DATE, TO_CHAR(J.last_start_date, 'YYYY-MM-DD HH24:mi:ss') last_start_date, (J.LAST_RUN_DURATION) LAST_RUN_DURATION, j.run_count, j.NUMBER_OF_ARGUMENTS, j.ENABLED, j.AUTO_DROP, j.max_run_duration, j.max_failures, j.max_runs, j.LOGGING_LEVEL, j.SYSTEM is_systemjob, j.comments, RJ.running_instance, RJ.cpu_used, B.username, B.SID, B.SERIAL#, (SELECT nb.spid FROM gv$process nb WHERE nb.ADDR = b.SADDR and nb.inst_id=b.inst_id and nb.con_id=b.con_id) spid, b.STATUS, B.COMMAND, B.LOGON_TIME, B.OSUSER FROM cdb_scheduler_jobs j LEFT OUTER JOIN cdb_scheduler_running_jobs rj ON (j.JOB_NAME = rj.JOB_NAME and j.CON_ID = rj.CON_ID) LEFT OUTER JOIN gv$session b ON (rj.session_id = b.SID AND rj.RUNNING_INSTANCE = b.INST_ID and j.CON_ID = b.con_id) ORDER BY j.CON_ID, b.INST_ID, j.STATE, j.owner, j.JOB_NAME; prompt
prompt prompt jobError Message [Next Item]
prompt NOTE: ,job3 CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN LOG_DATE FORMAT a240 HEADING ' LOG_DATE ' ENTMAP OFF COLUMN detail_ADDITIONAL_INFO FORMAT a200 HEADING ' DETAIL_ADDITIONAL_INFO ' COLUMN log_ADDITIONAL_INFO FORMAT a200 HEADING ' LOG_ADDITIONAL_INFO ' ENTMAP OFF COLUMN run_duration FORMAT a200 HEADING ' run_duration ' COLUMN ACTUAL_START_DATE FORMAT a240 HEADING ' ACTUAL_START_DATE ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT n.CON_ID, n.OWNER, n.log_id, n.job_name, n.job_class, TO_CHAR(n.log_date, 'YYYY-MM-DD HH24:mi:ss') LOG_DATE, n.OPERATION, n.status, jrd.error#, jrd.run_duration, TO_CHAR(jrd.ACTUAL_START_DATE, 'YYYY-MM-DD HH24:mi:ss') ACTUAL_START_DATE, jrd.INSTANCE_ID, jrd.SESSION_ID, jrd.SLAVE_PID, n.additional_info log_ADDITIONAL_INFO, jrd.ADDITIONAL_INFO detail_ADDITIONAL_INFO, DENSE_RANK() over(partition by n.OWNER, n.JOB_NAME ORDER BY n.LOG_ID desc) rank_order FROM cdb_scheduler_job_log N, cdb_scheduler_job_run_details jrd WHERE n.log_id = jrd.log_id(+) and n.CON_ID = jrd.CON_ID(+) AND n.STATUS <> 'SUCCEEDED' and n.job_name not like 'ORA$AT_OS_OPT_SY%' AND n.log_date >= sysdate - 7 ORDER BY n.log_date DESC) WHERE rank_order <= 3; prompt
-- +============================================================================+ -- | | -- | <<<<< BACKUPS >>>>> | -- | | -- +============================================================================+ host echo " RMAN. . ." prompt prompt RMAN
prompt
prompt ● Last 20 RMAN backup jobs CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN backup_name FORMAT a130 HEADING 'Backup Name' ENTMAP OFF COLUMN START_TIME FORMAT a75 HEADING 'Start Time' ENTMAP OFF COLUMN elapsed_time FORMAT a75 HEADING '' ENTMAP OFF COLUMN status HEADING '' ENTMAP OFF COLUMN input_type HEADING '' ENTMAP OFF COLUMN output_device_type HEADING '' ENTMAP OFF COLUMN input_size HEADING '' ENTMAP OFF COLUMN output_size HEADING '' ENTMAP OFF COLUMN INPUT_BYTES_PER_SEC HEADING 'IO' ENTMAP OFF COLUMN output_rate_per_sec HEADING 'IO' ENTMAP OFF SELECT '
prompt ● All non-default RMAN configuration settings CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN name FORMAT a130 HEADING 'Name' ENTMAP OFF COLUMN value HEADING 'Value' ENTMAP OFF SELECT '
prompt prompt RMANAll Backups[Next Item]
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN BACKUP_TYPE FORMAT a80 HEADING ' BACKUP_TYPE ' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN END_TIME FORMAT a140 HEADING ' END_TIME ' ENTMAP OFF COLUMN KEEP_UNTIL FORMAT a140 HEADING ' KEEP_UNTIL ' ENTMAP OFF COLUMN INCREMENTAL_LEVEL HEADING 'INCREMENTAL|LEVEL' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON SELECT BS_key, BP_key, BACKUP_TYPE, INCREMENTAL_LEVEL, START_TIME START_TIME, END_TIME, ELAPSED_TIME, piece_name, bs_size, DEVICE_TYPE, TAG, CONTROLFILE_INCLUDED, bs_status, bs_compressed, KEEP, KEEP_UNTIL, KEEP_OPTIONS, sum(case WHEN datafileNAME IS NOT NULL then 1 else 0 end) datafiles, sum(case WHEN SEQUENCE# IS NOT NULL then 1 else 0 end) archivelog, sum(case WHEN DB_UNIQUE_NAME IS NOT NULL then 1 else 0 end) spfile, sum(case WHEN cf_CHECKPOINT_CHANGE# IS NOT NULL then 1 else 0 end) controlfile FROM (SELECT a.RECID BS_key, c.RECID BP_key, case WHEN a.backup_type = 'L' then '
prompt prompt RMANAll BackupsDetails[Next Item]
prompt NOTE: CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN BACKUP_TYPE FORMAT a80 HEADING ' BACKUP_TYPE ' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN END_TIME FORMAT a140 HEADING ' END_TIME ' ENTMAP OFF COLUMN INCREMENTAL_LEVEL HEADING 'INCREMENTAL|LEVEL' ENTMAP OFF COLUMN FIRST_TIME FORMAT a240 HEADING ' FIRST_TIME ' ENTMAP OFF COLUMN NEXT_TIME FORMAT a240 HEADING ' NEXT_TIME ' ENTMAP OFF COLUMN CREATION_TIME FORMAT a140 HEADING ' CREATION_TIME ' ENTMAP OFF COLUMN df_CHECKPOINT_CHANGE# FORMAT a50 HEADING 'DF_CHECKPOINT_CHANGE#' ENTMAP OFF COLUMN KEEP_UNTIL FORMAT a140 HEADING ' KEEP_UNTIL ' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON SELECT DISTINCT * FROM (SELECT BS_KEY, BP_KEY, BACKUP_TYPE, INCREMENTAL_LEVEL, BS_SIZE, START_TIME, END_TIME, ELAPSED_TIME, PIECE_NAME, DEVICE_TYPE, TAG, BS_STATUS, BS_COMPRESSED, CONTROLFILE_INCLUDED, KEEP, KEEP_UNTIL, KEEP_OPTIONS, FILE#, DF_INCREMENTAL_LEVEL, DATAFILENAME, USED_CHANGE_TRACKING, DF_CHECKPOINT_CHANGE#, DF_CHECKPOINT_TIME, THREAD#, SEQUENCE#, RESETLOGS_CHANGE#, FIRST_CHANGE#, FIRST_TIME, NEXT_CHANGE#, NEXT_TIME, MODIFICATION_TIME, DB_UNIQUE_NAME, CREATION_TIME, CF_CHECKPOINT_CHANGE#, CF_CHECKPOINT_TIME, FILESIZE_DISPLAY, DENSE_RANK() OVER(PARTITION BY BACKUP_TYPE ORDER BY START_TIME DESC) RANK_ORDER FROM (SELECT a.RECID BS_key, c.RECID BP_key, case WHEN a.backup_type = 'L' then '
-- +----------------------------------------------------------------------------+ -- | - RMAN BACKUP SETS - | -- +----------------------------------------------------------------------------+ prompt prompt RMAN
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP OFF COLUMN BACKUP_TYPE FORMAT a80 HEADING ' BACKUP_TYPE ' ENTMAP OFF COLUMN device_type HEADING 'Device Type' ENTMAP OFF COLUMN controlfile_included FORMAT a30 HEADING 'Controlfile Included?' ENTMAP OFF COLUMN spfile_included FORMAT a30 HEADING 'SPFILE Included?' ENTMAP OFF COLUMN incremental_level HEADING 'Incremental Level' ENTMAP OFF COLUMN pieces FORMAT 999,999,999,999 HEADING '# of Pieces' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN completion_time FORMAT a180 HEADING ' END_TIME ' ENTMAP OFF COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP OFF COLUMN tag HEADING 'Tag' ENTMAP OFF COLUMN block_size FORMAT 999,999,999,999,999 HEADING 'Block Size' ENTMAP OFF COLUMN keep FORMAT a40 HEADING 'Keep?' ENTMAP OFF COLUMN keep_options FORMAT a15 HEADING 'Keep Options' ENTMAP OFF COLUMN KEEP_UNTIL FORMAT a140 HEADING ' KEEP_UNTIL ' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON -- BREAK ON report COMPUTE sum LABEL 'Total:' OF pieces elapsed_seconds ON report SELECT '
') || '
-- +----------------------------------------------------------------------------+ -- | - RMAN BACKUP PIECES - | -- +----------------------------------------------------------------------------+ prompt prompt RMANBackup Pieces
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP OFF COLUMN piece# HEADING 'Piece #' ENTMAP OFF COLUMN copy# HEADING 'Copy #' ENTMAP OFF COLUMN bp_key HEADING 'BP Key' ENTMAP OFF COLUMN status HEADING 'Status' ENTMAP OFF COLUMN handle HEADING 'Handle' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN completion_time FORMAT a75 HEADING 'End Time' ENTMAP OFF COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP OFF COLUMN deleted FORMAT a10 HEADING 'Deleted?' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON ---- BREAK ON bs_key SELECT '
-- +----------------------------------------------------------------------------+ -- | - RMAN BACKUP CONTROL FILES - | -- +----------------------------------------------------------------------------+ prompt prompt RMAN Control File
prompt ● Available automatic control files within all available (and expired) backup sets CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP OFF COLUMN piece# HEADING 'Piece #' ENTMAP OFF COLUMN copy# HEADING 'Copy #' ENTMAP OFF COLUMN bp_key HEADING 'BP Key' ENTMAP OFF COLUMN controlfile_included FORMAT a75 HEADING 'Controlfile Included?' ENTMAP OFF COLUMN status HEADING 'Status' ENTMAP OFF COLUMN handle HEADING 'Handle' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN completion_time FORMAT a40 HEADING 'End Time' ENTMAP OFF COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP OFF COLUMN deleted FORMAT a10 HEADING 'Deleted?' ENTMAP OFF COLUMN KEEP_UNTIL FORMAT a140 HEADING ' KEEP_UNTIL ' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON ---- BREAK ON bs_key SELECT '
-- +----------------------------------------------------------------------------+ -- | - RMAN BACKUP SPFILE - | -- +----------------------------------------------------------------------------+ prompt prompt RMAN SPFILE
prompt ● Available automatic SPFILE backups within all available (and expired) backup sets CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP OFF COLUMN piece# HEADING 'Piece #' ENTMAP OFF COLUMN copy# HEADING 'Copy #' ENTMAP OFF COLUMN bp_key HEADING 'BP Key' ENTMAP OFF COLUMN spfile_included FORMAT a75 HEADING 'SPFILE Included?' ENTMAP OFF COLUMN status HEADING 'Status' ENTMAP OFF COLUMN handle HEADING 'Handle' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN completion_time FORMAT a40 HEADING 'End Time' ENTMAP OFF COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP OFF COLUMN deleted FORMAT a10 HEADING 'Deleted?' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON -- BREAK ON bs_key SELECT '
-- +----------------------------------------------------------------------------+ -- | - RMAN BACKUP Archived Redo Logs - | -- +----------------------------------------------------------------------------+ prompt prompt RMAN [Next Item]
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN BACKUP_TYPE FORMAT a80 HEADING ' BACKUP_TYPE ' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN END_TIME FORMAT a140 HEADING ' END_TIME ' ENTMAP OFF COLUMN INCREMENTAL_LEVEL HEADING 'INCREMENTAL|LEVEL' ENTMAP OFF COLUMN FIRST_TIME FORMAT a140 HEADING ' FIRST_TIME ' ENTMAP OFF COLUMN NEXT_TIME FORMAT a140 HEADING ' NEXT_TIME ' ENTMAP OFF COLUMN CREATION_TIME FORMAT a140 HEADING ' CREATION_TIME ' ENTMAP OFF COLUMN DF_CHECKPOINT_TIME FORMAT a140 HEADING ' DF_CHECKPOINT_TIME ' ENTMAP OFF COLUMN MODIFICATION_TIME FORMAT a140 HEADING ' MODIFICATION_TIME ' ENTMAP OFF COLUMN cf_CHECKPOINT_TIME FORMAT a140 HEADING ' cf_CHECKPOINT_TIME ' ENTMAP OFF SET DEFINE ON SELECT A.BS_KEY, A.BP_KEY, A.BACKUP_TYPE, A.INCREMENTAL_LEVEL, A.BS_SIZE, A.START_TIME, A.END_TIME, A.ELAPSED_TIME, A.PIECE_NAME, A.DEVICE_TYPE, A.TAG, A.BS_STATUS, A.BS_COMPRESSED, A.CONTROLFILE_INCLUDED, A.KEEP, A.THREAD#, A.SEQUENCE#, A.RESETLOGS_CHANGE#, A.FIRST_CHANGE#, A.FIRST_TIME, A.NEXT_CHANGE#, A.NEXT_TIME FROM (SELECT a.RECID BS_key, c.RECID BP_key, case WHEN a.backup_type = 'L' then '
-- +============================================================================+ -- | | -- | <<<<< FLASHBACK TECHNOLOGIES >>>>> | -- | | -- +============================================================================+ prompt prompt
prompt NOTE: db_flashback_retention_target is specified in minutes; db_recovery_file_dest_size is specified in bytes CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a95 HEADING 'Instance_Name' ENTMAP OFF COLUMN thread_number_print FORMAT a95 HEADING 'Thread Number' ENTMAP OFF COLUMN name FORMAT a125 HEADING 'Name' ENTMAP OFF COLUMN value HEADING 'Value' ENTMAP OFF SET DEFINE ON -- BREAK ON report ON instance_name_print ON thread_number_print SELECT '
-- +----------------------------------------------------------------------------+ -- | - FLASHBACK DATABASE STATUS - | -- +----------------------------------------------------------------------------+ prompt prompt ● Flashback Database Status
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN dbid HEADING 'DB ID' ENTMAP OFF COLUMN name FORMAT A75 HEADING 'DB Name' ENTMAP OFF COLUMN log_mode FORMAT A75 HEADING 'Log Mode' ENTMAP OFF COLUMN flashback_on FORMAT A75 HEADING 'Flashback DB On?' ENTMAP OFF SELECT '
-- +----------------------------------------------------------------------------+ -- | - FLASHBACK DATABASE REDO TIME MATRIX - | -- +----------------------------------------------------------------------------+ prompt prompt ● Flashback Database Redo Time Matrix
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN begin_time FORMAT a75 HEADING 'Begin Time' ENTMAP OFF COLUMN END_TIME FORMAT a140 HEADING ' END_TIME ' ENTMAP OFF COLUMN flashback_data FORMAT 9,999,999,999,999 HEADING 'Flashback Data' ENTMAP OFF COLUMN db_data FORMAT 9,999,999,999,999 HEADING 'DB Data' ENTMAP OFF COLUMN redo_data FORMAT 9,999,999,999,999 HEADING 'Redo Data' ENTMAP OFF COLUMN estimated_flashback_size FORMAT 9,999,999,999,999 HEADING 'Estimated Flashback Size' ENTMAP OFF SET DEFINE ON SELECT '
-- +----------------------------------------------------------------------------+ -- | - ARCHIVING MODE - | -- +----------------------------------------------------------------------------+ host echo " . . ." prompt prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - ARCHIVING MODE - | -- +----------------------------------------------------------------------------+ prompt prompt Archiving Mode
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN db_log_mode FORMAT a95 HEADING 'Database|Log Mode' ENTMAP OFF COLUMN log_archive_start FORMAT a95 HEADING 'Automatic|Archival' ENTMAP OFF COLUMN oldest_online_log_sequence FORMAT 999999999999999 HEADING 'Oldest Online |Log Sequence' ENTMAP OFF COLUMN current_log_seq FORMAT 999999999999999 HEADING 'Current |Log Sequence' ENTMAP OFF SET DEFINE ON SELECT '
-- +----------------------------------------------------------------------------+ -- | - ARCHIVE DESTINATIONS - | -- +----------------------------------------------------------------------------+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN name HEADING 'Parameter Name' ENTMAP OFF COLUMN value HEADING 'Parameter Value' ENTMAP OFF SELECT '' || a.name || '' name , a.value value FROM v$parameter a WHERE a.name like 'log_%' ORDER BY a.name; prompt
prompt prompt Archive Destinations
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN dest_id HEADING 'Destination|ID' ENTMAP OFF COLUMN dest_name HEADING 'Destination|Name' ENTMAP OFF COLUMN destination HEADING 'Destination' ENTMAP OFF COLUMN status HEADING 'Status' ENTMAP OFF COLUMN schedule HEADING 'Schedule' ENTMAP OFF COLUMN archiver HEADING 'Archiver' ENTMAP OFF COLUMN log_sequence FORMAT 999999999999999 HEADING 'Current Log|Sequence' ENTMAP OFF SELECT '
-- +----------------------------------------------------------------------------+ -- | - ARCHIVING HISTORY - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt prompt ● Archived Logs Status (Past Month)
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN thread# FORMAT a79 HEADING '' ENTMAP OFF COLUMN f_time FORMAT a75 HEADING '' ENTMAP OFF COLUMN day_arch FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN hour_arch FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF -- BREAK ON report ON thread# SELECT '
prompt NOTE: DB_RECOVERY_FILE_DEST_SIZE,crosscheck archivelog all; delete expired archivelog all; prompt NOTE: ,View CLEAR COLUMNS COMPUTES SET DEFINE ON SELECT A.NAME, round(a.SPACE_LIMIT / 1024 / 1024) SPACE_LIMIT_m, (a.space_used / 1024 / 1024) space_used_m, round(a.space_used / a.SPACE_LIMIT, 2) PERCENT_SPACE_USED, round(a.space_reclaimable / 1024 / 1024, 2) space_reclaimable, round(a.space_reclaimable / a.SPACE_LIMIT, 2) PERCENT_SPACE_RECLAIMABLE, number_of_files FROM v$recovery_file_dest A WHERE a.SPACE_LIMIT <> 0 UNION ALL SELECT b.FILE_TYPE, (c.SPACE_LIMIT / 1024 / 1024) SPACE_LIMIT_m, round(b.PERCENT_SPACE_USED * c.SPACE_LIMIT / 1024 / 1024 / 100, 2) space_used_m, b.PERCENT_SPACE_USED PERCENT_SPACE_USED, round(b.PERCENT_SPACE_RECLAIMABLE * c.SPACE_LIMIT / 1024 / 1024 / 100, 2) space_reclaimable, (b.PERCENT_SPACE_RECLAIMABLE) PERCENT_SPACE_RECLAIMABLE, b.NUMBER_OF_FILES FROM v$flash_recovery_area_usage b, v$recovery_file_dest c WHERE c.SPACE_LIMIT <> 0 UNION ALL SELECT bb.FILENAME || ' ---' || bb.STATUS, (c.SPACE_LIMIT / 1024 / 1024) SPACE_LIMIT_m, (bb.BYTES / 1024 / 1024) space_used, round(bb.BYTES * 100 / c.SPACE_LIMIT, 2) PERCENT_SPACE_USED, 0, 0, 1 FROM v$block_change_tracking bb, v$recovery_file_dest c WHERE c.SPACE_LIMIT <> 0; prompt
prompt prompt 7 [Next Item]
prompt ● first_time,,top500 CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN FIRST_TIME FORMAT a140 HEADING ' FIRST_TIME ' ENTMAP OFF COLUMN END_TIME FORMAT a140 HEADING ' END_TIME ' ENTMAP OFF SET DEFINE ON -- BREAK ON THREAD# SELECT * FROM ( SELECT t.THREAD#, t.SEQUENCE#, t.FIRST_TIME, nvl(T.END_TIME, (SELECT NB.FIRST_TIME FROM v$log nb WHERE nb.SEQUENCE# = t.SEQUENCE# + 1 AND nb.THREAD# = t.THREAD#)) END_TIME, round(((nvl(T.END_TIME, (SELECT NB.FIRST_TIME FROM v$log nb WHERE nb.SEQUENCE# = t.SEQUENCE# + 1 AND nb.THREAD# = t.THREAD#)) - t.FIRST_TIME) * 24) * 60, 2) total_min, ROUND(t.BLOCKS * t.BLOCK_SIZE / 1024 / 1024, 3) LOGsize_m, t.NAME, '
prompt ● ,30,24, COLUMN TOTAL HEADING 'TOTAL' ENTMAP OFF CLEAR COLUMNS COMPUTES SET DEFINE OFF -- BREAK ON report on THREAD# skip 1 --COMPUTE sum LABEL 'Total: ' avg label 'Average: ' OF TOTAL ON report COMPUTE sum LABEL 'Sum: ' OF TOTAL ON THREAD# --COMPUTE avg LABEL 'Average: ' OF TOTAL ON report --COMPUTE sum LABEL 'Total:' avg label 'Average:' OF TOTAL ON report SELECT a.THREAD#, '
-- +----------------------------------------------------------------------------+ -- | - ONLINE REDO LOGS - | -- +----------------------------------------------------------------------------+ prompt prompt Log Group Size
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT a.group#, a.THREAD#, a.SEQUENCE#, bytes / 1024 / 1024 size_m, a.status, a.ARCHIVED, a.MEMBERS, TO_CHAR(listagg(b.MEMBER,',') within group(order by MEMBER)) MEMBER, b.TYPE FROM gv$log a, gv$logfile b WHERE b.GROUP# = a.GROUP# AND a.THREAD# = b.INST_ID GROUP BY a.GROUP#, a.THREAD#, a.SEQUENCE#, a.BYTES, a.STATUS, a.ARCHIVED, a.MEMBERS, b.TYPE ORDER BY a.THREAD#, a.GROUP#, a.SEQUENCE#; prompt
-- +============================================================================+ -- | | -- | <<<<< PERFORMANCE >>>>> | -- | | -- +============================================================================+ -- +----------------------------------------------------------------------------+ -- | - SGA INFORMATION - | -- +----------------------------------------------------------------------------+ host echo " SGA. . ." prompt prompt SGA
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN inst_id FORMAT 999 COLUMN name FORMAT a75 COLUMN MBytes FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN resizeable FORMAT a75 HEADING '' ENTMAP OFF -- BREAK ON report on inst_id SELECT inst_id,name,round(bytes/1024/1024) MBytes ,resizeable FROM gv$sgainfo; prompt
prompt prompt SGA
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name FORMAT a79 HEADING 'Instance_Name' ENTMAP OFF COLUMN name FORMAT a150 HEADING 'Pool Name' ENTMAP OFF COLUMN value FORMAT 999,999,999,999,999 HEADING 'Bytes' ENTMAP OFF -- BREAK ON report ON instance_name COMPUTE sum LABEL 'Total:' OF value ON instance_name SELECT '
-- +----------------------------------------------------------------------------+ -- | - SGA TARGET ADVICE - | -- +----------------------------------------------------------------------------+ prompt prompt SGA Target Advice
prompt Modify the SGA_TARGET parameter (up to the size of the SGA_MAX_SIZE, if necessary) to reduce the number of "Estimated Physical Reads". CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name FORMAT a79 HEADING 'Instance_Name' ENTMAP OFF COLUMN name FORMAT a79 HEADING 'Parameter Name' ENTMAP OFF COLUMN value FORMAT a79 HEADING 'Value' ENTMAP OFF -- BREAK ON report ON instance_name SELECT '
-- +----------------------------------------------------------------------------+ -- | - SGA (ASMM) DYNAMIC COMPONENTS - | -- +----------------------------------------------------------------------------+ prompt prompt SGA (ASMM) Dynamic Components
prompt Provides a summary report of all dynamic components AS part of the Automatic Shared Memory prompt Management (ASMM) configuration. This will display the total real memory allocation for the current prompt SGA FROM the V$SGA_DYNAMIC_COMPONENTS view, which contains both manual AND autotuned SGA components. prompt AS with the other manageability features of Oracle Database 10g, ASMM requires you to set the prompt STATISTICS_LEVEL parameter to at least TYPICAL (the default) before attempting to enable ASMM. ASMM prompt can be enabled by setting SGA_TARGET to a nonzero value in the initialization parameter file (pfile/spfile). CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name FORMAT a79 HEADING 'Instance_Name' ENTMAP OFF COLUMN component FORMAT a79 HEADING 'Component Name' ENTMAP OFF COLUMN current_size FORMAT 999,999,999,999 HEADING 'Current Size' ENTMAP OFF COLUMN min_size FORMAT 999,999,999,999 HEADING 'Min Size' ENTMAP OFF COLUMN max_size FORMAT 999,999,999,999 HEADING 'Max Size' ENTMAP OFF COLUMN user_specified_size FORMAT 999,999,999,999 HEADING 'User Specified|Size' ENTMAP OFF COLUMN oper_count FORMAT 999,999,999,999 HEADING 'Oper.|Count' ENTMAP OFF COLUMN last_oper_type FORMAT a75 HEADING 'Last Oper.|Type' ENTMAP OFF COLUMN last_oper_mode FORMAT a75 HEADING 'Last Oper.|Mode' ENTMAP OFF COLUMN last_oper_time FORMAT a75 HEADING 'Last Oper.|Time' ENTMAP OFF COLUMN granule_size FORMAT 999,999,999,999 HEADING 'Granule Size' ENTMAP OFF -- BREAK ON report ON instance_name SELECT '
') || '
-- +----------------------------------------------------------------------------+ -- | - PGA TARGET ADVICE - | -- +----------------------------------------------------------------------------+ prompt prompt PGA Target
prompt The V$PGA_TARGET_ADVICE view predicts how the statistics cache hit percentage AND over prompt allocation count in V$PGASTAT will be impacted if you change the value of the prompt initialization parameter PGA_AGGREGATE_TARGET. WHEN you set the PGA_AGGREGATE_TARGET and prompt WORKAREA_SIZE_POLICY to AUTO then the *_AREA_SIZE parameter are automatically ignored and prompt Oracle will automatically use the computed value for these parameters. Use the results from prompt the query below to adequately set the initialization parameter PGA_AGGREGATE_TARGET AS to avoid prompt any over allocation. If column ESTD_OVERALLOCATION_COUNT in the V$PGA_TARGET_ADVICE prompt view (below) is nonzero, it indicates that PGA_AGGREGATE_TARGET is too small to even prompt meet the minimum PGA memory needs. If PGA_AGGREGATE_TARGET is set within the over prompt allocation zone, the memory manager will over-allocate memory AND actual PGA memory prompt consumed will be more than the limit you set. It is therefore meaningless to set a prompt value of PGA_AGGREGATE_TARGET in that zone. After eliminating over-allocations, the prompt goal is to maximize the PGA cache hit percentage, based on your response-time requirement prompt AND memory constraints. CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name FORMAT a79 HEADING 'Instance_Name' ENTMAP OFF COLUMN name FORMAT a79 HEADING 'Parameter Name' ENTMAP OFF COLUMN value FORMAT a79 HEADING 'Value' ENTMAP OFF -- BREAK ON report ON instance_name SELECT '
-- +----------------------------------------------------------------------------+ -- | - FILE I/O STATISTICS - | -- +----------------------------------------------------------------------------+ host echo " IO. . ." prompt prompt IO
prompt
prompt Ordered by "Physical Reads" since last startup of the Oracle instance CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN tablespace_name FORMAT a50 HEAD 'Tablespace' ENTMAP OFF COLUMN fname HEAD 'File Name' ENTMAP OFF COLUMN phyrds FORMAT 999,999,999,999,999 HEAD 'Physical Reads' ENTMAP OFF COLUMN phywrts FORMAT 999,999,999,999,999 HEAD 'Physical Writes' ENTMAP OFF COLUMN read_pct HEAD 'Read Pct.' ENTMAP OFF COLUMN write_pct HEAD 'Write Pct.' ENTMAP OFF COLUMN total_io FORMAT 999,999,999,999,999 HEAD 'Total I/O' ENTMAP OFF -- BREAK ON report --COMPUTE sum LABEL 'Total: ' OF phyrds phywrts total_io ON report SELECT df.con_id, '' || df.tablespace_name || '' tablespace_name, df.file_name fname, fs.phyrds phyrds, '
-- +----------------------------------------------------------------------------+ -- | - FILE I/O TIMINGS - | -- +----------------------------------------------------------------------------+ prompt prompt IO
prompt Average time (in milliseconds) for an I/O call per datafile since last startup of the Oracle instance - (ordered by Physical Reads) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN fname HEAD 'File Name' ENTMAP OFF COLUMN phyrds FORMAT 999,999,999,999,999 HEAD 'Physical Reads' ENTMAP OFF COLUMN read_rate FORMAT 999,999,999,999,999.99 HEAD 'Average Read Time
(milliseconds per read)' ENTMAP OFF COLUMN phywrts FORMAT 999,999,999,999,999 HEAD 'Physical Writes' ENTMAP OFF COLUMN write_rate FORMAT 999,999,999,999,999.99 HEAD 'Average Write Time
(milliseconds per write)' ENTMAP OFF -- BREAK ON report --COMPUTE sum LABEL 'Total: ' OF phyrds phywrts ON report --COMPUTE avg LABEL 'Average: ' OF read_rate write_rate ON report SELECT s.CON_ID, '' || d.name || '' fname, s.phyrds phyrds, ROUND((s.readtim / GREATEST(s.phyrds, 1)), 2) read_rate, s.phywrts phywrts, ROUND((s.writetim / GREATEST(s.phywrts, 1)), 2) write_rate FROM v$filestat s, v$datafile d WHERE s.file# = d.file# and s.CON_ID=d.CON_ID UNION SELECT s.CON_ID, '' || t.name || '' fname, s.phyrds phyrds, ROUND((s.readtim / GREATEST(s.phyrds, 1)), 2) read_rate, s.phywrts phywrts, ROUND((s.writetim / GREATEST(s.phywrts, 1)), 2) write_rate FROM v$tempstat s, v$tempfile t WHERE s.file# = t.file# and s.CON_ID=t.CON_ID ORDER BY 1,3 DESC; prompt
-- +----------------------------------------------------------------------------+ -- | - AVERAGE OVERALL I/O PER SECOND - | -- +----------------------------------------------------------------------------+ prompt prompt Average Overall I/O per Second
prompt Average overall I/O calls (physical read/write calls) since last startup of the Oracle instance CLEAR COLUMNS COMPUTES SET DEFINE OFF DECLARE CURSOR get_file_io IS SELECT NVL(SUM(a.phyrds + a.phywrts), 0) sum_datafile_io , TO_NUMBER(null) sum_tempfile_io FROM v$filestat a UNION SELECT TO_NUMBER(null) sum_datafile_io , NVL(SUM(b.phyrds + b.phywrts), 0) sum_tempfile_io FROM v$tempstat b; current_time DATE; elapsed_time_seconds NUMBER; sum_datafile_io NUMBER; sum_datafile_io2 NUMBER; sum_tempfile_io NUMBER; sum_tempfile_io2 NUMBER; total_io NUMBER; datafile_io_per_sec NUMBER; tempfile_io_per_sec NUMBER; total_io_per_sec NUMBER; BEGIN OPEN get_file_io; FOR i IN 1..2 LOOP FETCH get_file_io INTO sum_datafile_io, sum_tempfile_io; IF i = 1 THEN sum_datafile_io2 := sum_datafile_io; ELSE sum_tempfile_io2 := sum_tempfile_io; END IF; END LOOP; total_io := sum_datafile_io2 + sum_tempfile_io2; SELECT sysdate INTO current_time FROM dual; SELECT CEIL ((current_time - startup_time)*(60*60*24)) INTO elapsed_time_seconds FROM v$instance; datafile_io_per_sec := sum_datafile_io2/elapsed_time_seconds; tempfile_io_per_sec := sum_tempfile_io2/elapsed_time_seconds; total_io_per_sec := total_io/elapsed_time_seconds; DBMS_OUTPUT.PUT_LINE('
Elapsed Time (in seconds) | ' || TO_CHAR(elapsed_time_seconds, '9,999,999,999,999') || ' |
---|---|
Datafile I/O Calls per Second | ' || TO_CHAR(datafile_io_per_sec, '9,999,999,999,999') || ' |
Tempfile I/O Calls per Second | ' || TO_CHAR(tempfile_io_per_sec, '9,999,999,999,999') || ' |
Total I/O Calls per Second | ' || TO_CHAR(total_io_per_sec, '9,999,999,999,999') || ' |
-- +----------------------------------------------------------------------------+ -- | - REDO LOG CONTENTION - | -- +----------------------------------------------------------------------------+ prompt prompt Redo Log Contention
prompt All latches like redo% - (ordered by misses) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN name FORMAT a95 HEADING 'Latch Name' COLUMN gets FORMAT 999,999,999,999,999,999 HEADING 'Gets' COLUMN misses FORMAT 999,999,999,999 HEADING 'Misses' COLUMN sleeps FORMAT 999,999,999,999 HEADING 'Sleeps' COLUMN immediate_gets FORMAT 999,999,999,999,999,999 HEADING 'Immediate Gets' COLUMN immediate_misses FORMAT 999,999,999,999 HEADING 'Immediate Misses' -- BREAK ON report COMPUTE sum LABEL 'Total:' OF gets misses sleeps immediate_gets immediate_misses ON report SELECT '
-- +----------------------------------------------------------------------------+ -- | - FULL TABLE SCANS - | -- +----------------------------------------------------------------------------+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN large_table_scans FORMAT 999,999,999,999,999 HEADING 'Large Table Scans' ENTMAP OFF COLUMN small_table_scans FORMAT 999,999,999,999,999 HEADING 'Small Table Scans' ENTMAP OFF COLUMN pct_large_scans HEADING 'Pct. Large Scans' ENTMAP OFF SELECT a.value large_table_scans , b.value small_table_scans , '
-- +----------------------------------------------------------------------------+ -- | - SORTS - | -- +----------------------------------------------------------------------------+ prompt prompt Sort Activity
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN disk_sorts FORMAT 999,999,999,999,999 HEADING 'Disk Sorts' ENTMAP OFF COLUMN memory_sorts FORMAT 999,999,999,999,999 HEADING 'Memory Sorts' ENTMAP OFF COLUMN pct_disk_sorts HEADING 'Pct. Disk Sorts' ENTMAP OFF SELECT a.value disk_sorts , b.value memory_sorts , '
-- +----------------------------------------------------------------------------+ -- | - OUTLINES - | -- +----------------------------------------------------------------------------+ prompt prompt Outlines
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN category FORMAT a125 HEADING 'Category' ENTMAP OFF COLUMN owner FORMAT a125 HEADING 'Owner' ENTMAP OFF COLUMN name FORMAT a125 HEADING 'Name' ENTMAP OFF COLUMN used HEADING 'Used?' ENTMAP OFF COLUMN timestamp FORMAT a125 HEADING 'Time Stamp' ENTMAP OFF COLUMN version HEADING 'Version' ENTMAP OFF COLUMN sql_text HEADING 'SQL Text' ENTMAP OFF SELECT d.CON_ID, '
-- +----------------------------------------------------------------------------+ -- | - OUTLINE HINTS - | -- +----------------------------------------------------------------------------+ prompt prompt Outline Hints
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN category FORMAT a125 HEADING 'Category' ENTMAP OFF COLUMN owner FORMAT a125 HEADING 'Owner' ENTMAP OFF COLUMN name FORMAT a125 HEADING 'Name' ENTMAP OFF COLUMN node HEADING 'Node' ENTMAP OFF COLUMN join_pos HEADING 'Join Position' ENTMAP OFF COLUMN hint HEADING 'Hint' ENTMAP OFF -- BREAK ON category ON owner ON name SELECT a.CON_ID, '
-- +----------------------------------------------------------------------------+ -- | - SQL STATEMENTS WITH MOST BUFFER GETS - | -- +----------------------------------------------------------------------------+ host echo " SQL. . ." prompt prompt SQL
prompt
prompt NOTE: Excluding all internal system schemas (i.e. SYS, SYSTEM, db_monitor) ,SELECT database lever top 10 rows prompt prompt TOP10SQL
prompt NOTE: Top 10 SQL statements with buffer gets greater than 1000 CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN buffer_gets FORMAT 999,999,999,999,999 HEADING 'Buffer Gets' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN gets_per_exec FORMAT 999,999,999,999,999 HEADING 'Buffer Gets / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.buffer_gets desc) rank_order FROM gv$sqlarea ai WHERE buffer_gets > 1000 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.buffer_gets DESC; prompt
-- +----------------------------------------------------------------------------+ -- | - SQL STATEMENTS WITH MOST DISK READS - | -- +----------------------------------------------------------------------------+ prompt prompt TOP10SQL
prompt NOTE: Top 10 SQL statements with disk reads greater than 1000 CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.DISK_READS desc) rank_order FROM gv$sqlarea ai WHERE buffer_gets > 1000 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.DISK_READS DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.ELAPSED_TIME desc) rank_order FROM gv$sqlarea ai WHERE buffer_gets > 1000 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.ELAPSED_TIME DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.EXECUTIONS desc) rank_order FROM gv$sqlarea ai WHERE buffer_gets > 1000 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.EXECUTIONS DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.PARSE_CALLS desc) rank_order FROM gv$sqlarea ai WHERE buffer_gets > 1000 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.EXECUTIONS DESC; prompt
prompt prompt VERSION_COUNT TOP10SQL
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.VERSION_COUNT desc) rank_order FROM gv$sqlarea ai WHERE buffer_gets > 1000 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.VERSION_COUNT DESC; prompt
prompt NOTE: shared memory,SQLlibrary cacheTOP SQL CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT INST_ID, '' || UPPER(username) || '' username, SQL_ID, A.sharable_mem_m, a.buffer_gets buffer_gets, DISK_READS, LAST_LOAD_TIME, LAST_ACTIVE_TIME, a.executions, PARSE_CALLS, VERSION_COUNT, loads, ((ELAPSED_TIME / 1000000)) ELAPSED_TIME, round(a.buffer_gets / DECODE(a.executions, 0, 1, a.executions), 3) buffer_gets_per_exec, round(a.disk_reads / DECODE(a.executions, 0, 1, a.executions), 3) disk_reads_per_exec, (a.ELAPSED_TIME / 1000000 / DECODE(a.executions, 0, 1, a.executions)) ELAPSED_TIME_per_exec, client_info, a.sql_text sql_text FROM (SELECT ai.INST_ID, round(ai.sharable_mem/1024/1024) sharable_mem_m, ai.buffer_gets, ai.DISK_READS, ai.executions, ai.PARSE_CALLS, ai.sql_text, ai.parsing_user_id, ai.SQL_ID, ai.ELAPSED_TIME, ai.LAST_LOAD_TIME, ai.LAST_ACTIVE_TIME, PARSING_SCHEMA_NAME username, VERSION_COUNT, loads, ai.MODULE || ' --' || ai.ACTION client_info, DENSE_RANK() over(ORDER BY ai.DISK_READS desc) rank_order FROM gv$sqlarea ai WHERE sharable_mem > 0.1*1024*1024 AND ai.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND ai.ACTION not in ('JOB_AUTO_TUNING_SQL_LHR') AND ai.SQL_TEXT NOT LIKE '/* SQL Analyze(%' ) a WHERE rank_order <= 10 ORDER BY INST_ID, a.DISK_READS DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT SESS.INST_ID, SESS.USERNAME, SESS.SID, SESS.SERIAL#, SORT1.SQL_ID, ((SQL.ELAPSED_TIME / SQL.EXECUTIONS / 1000000)) ELAPSED_TIME, SQL.SQL_TEXT, SQL.ADDRESS, SORT1.BLOCKS FROM GV$SESSION SESS, GV$SQLAREA SQL, GV$SORT_USAGE SORT1 WHERE SESS.SERIAL# = SORT1.SESSION_NUM AND SORT1.SQLADDR = SQL.ADDRESS AND SORT1.SQLHASH = SQL.HASH_VALUE AND SESS.INST_ID = SQL.INST_ID AND SESS.INST_ID = SORT1.INST_ID AND SORT1.BLOCKS > 200 ORDER BY SESS.INST_ID, SORT1.BLOCKS DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP OFF COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP OFF COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP OFF COLUMN sql_text FORMAT a500 HEADING ' SQL_Text ' ENTMAP OFF COLUMN LAST_LOAD_TIME FORMAT a140 HEADING ' LAST_LOAD_TIME ' ENTMAP OFF COLUMN LAST_ACTIVE_TIME FORMAT a140 HEADING ' LAST_ACTIVE_TIME ' ENTMAP OFF COLUMN client_info FORMAT a100 HEADING ' CLIENT_INFO ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT * FROM (SELECT DISTINCT ASH.INST_ID, ASH.SESSION_ID SID, ASH.SESSION_SERIAL# SERIAL#, GVS.PARSING_SCHEMA_NAME USERNAME, ASH.SESSION_TYPE, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, ASH.SQL_OPNAME, ASH.EVENT, ASH.SESSION_STATE, ASH.BLOCKING_SESSION, ASH.BLOCKING_SESSION_SERIAL#, ASH.BLOCKING_INST_ID BLOCKING_INSTANCE, ASH.SQL_EXEC_ID, ASH.SQL_EXEC_START, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || ' --' || ASH.MACHINE || '--' || ASH.CLIENT_ID || ' --' || ASH.SESSION_TYPE) SESSION_INFO, COUNT(*) ASH_COUNTS, (GVS.ELAPSED_TIME / 1000000) ELAPSED_TIME_S, (GVS.CPU_TIME / 1000000) CPU_TIME, GVS.EXECUTIONS, GVS.DISK_READS, GVS.BUFFER_GETS, GVS.LAST_ACTIVE_TIME, GVS.LAST_LOAD_TIME, GVS.PHYSICAL_READ_BYTES, GVS.PHYSICAL_WRITE_BYTES, GVS.SQL_TEXT, DENSE_RANK() OVER(ORDER BY COUNT(*) DESC) RANK_ORDER WHERE ASH.INST_ID = GVS.INST_ID AND GVS.SQL_ID = ASH.SQL_ID AND ASH.SQL_ID IS NOT NULL AND GVS.DISK_READS >= 100 GROUP BY ASH.INST_ID, ASH.SESSION_ID, ASH.SESSION_SERIAL#, ASH.SESSION_TYPE, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, ASH.SQL_OPNAME, ASH.SQL_EXEC_ID, ASH.EVENT, ASH.SESSION_STATE, ASH.BLOCKING_SESSION, ASH.BLOCKING_SESSION_SERIAL#, ASH.BLOCKING_INST_ID, ASH.CLIENT_ID, ASH.MACHINE, GVS.PARSING_SCHEMA_NAME, ASH.SQL_EXEC_START, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.MACHINE || ' --' || ASH.CLIENT_ID || '--' || ASH.SESSION_TYPE), (GVS.ELAPSED_TIME / 1000000), (GVS.CPU_TIME / 1000000), GVS.EXECUTIONS, GVS.DISK_READS, GVS.BUFFER_GETS, GVS.LAST_ACTIVE_TIME, GVS.LAST_LOAD_TIME, GVS.PHYSICAL_READ_BYTES, GVS.PHYSICAL_WRITE_BYTES, GVS.SQL_TEXT HAVING COUNT(*) > 10) V WHERE RANK_ORDER <= 10 ORDER BY V.INST_ID, V.SID, V.SERIAL#, V.SESSION_TYPE, V.SQL_ID) WHERE ROWNUM<=100; prompt ● CPUSQL SELECT ASH.INST_ID, ASH.SQL_ID, (SELECT VS.SQL_TEXT FROM GV$SQLAREA VS WHERE VS.SQL_ID = ASH.SQL_ID AND ASH.INST_ID = VS.INST_ID AND ROWNUM<=1) SQL_TEXT, ASH.SQL_CHILD_NUMBER, ASH.SESSION_INFO, COUNTS, PCTLOAD * 100 || '%' PCTLOAD FROM (SELECT ASH.INST_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.CLIENT_ID || ' --' || ASH.SESSION_TYPE) SESSION_INFO, COUNT(*) COUNTS, ROUND(COUNT(*) / SUM(COUNT(*)) OVER(), 2) PCTLOAD, DENSE_RANK() OVER(ORDER BY COUNT(*) DESC) RANK_ORDER WHERE ASH.SESSION_TYPE <> 'BACKGROUND' AND ASH.SESSION_STATE = 'ON CPU' GROUP BY ASH.INST_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.CLIENT_ID || ' --' || ASH.SESSION_TYPE)) ASH WHERE RANK_ORDER <= 10 ORDER BY COUNTS DESC; prompt ● I/OSQL SELECT ASH.INST_ID, ASH.SQL_ID, (SELECT VS.SQL_TEXT FROM GV$SQLAREA VS WHERE VS.SQL_ID = ASH.SQL_ID AND ASH.INST_ID = VS.INST_ID AND ROWNUM<=1) SQL_TEXT, ASH.SQL_CHILD_NUMBER, ASH.SESSION_INFO, COUNTS, PCTLOAD * 100 || '%' PCTLOAD FROM (SELECT ASH.INST_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.CLIENT_ID || ' --' || ASH.SESSION_TYPE) SESSION_INFO, COUNT(*) COUNTS, ROUND(COUNT(*) / SUM(COUNT(*)) OVER(), 2) PCTLOAD, DENSE_RANK() OVER(ORDER BY COUNT(*) DESC) RANK_ORDER WHERE ASH.SESSION_TYPE <> 'BACKGROUND' AND ASH.SESSION_STATE = 'WAITING' AND ASH.WAIT_CLASS = 'USER I/O' GROUP BY ASH.INST_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.CLIENT_ID || ' --' || ASH.SESSION_TYPE)) ASH WHERE RANK_ORDER <= 10 ORDER BY COUNTS DESC; prompt ● SQL SELECT ASH.INST_ID, ASH.SQL_ID, (SELECT VS.SQL_TEXT FROM GV$SQLAREA VS WHERE VS.SQL_ID = ASH.SQL_ID AND ASH.INST_ID = VS.INST_ID AND ROWNUM<=1) SQL_TEXT, ASH.SQL_CHILD_NUMBER, ASH.SESSION_INFO, "CPU", "WAIT", "IO", "TOTAL" FROM (SELECT ASH.INST_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.CLIENT_ID || '--' || ASH.SESSION_TYPE) SESSION_INFO, SUM(DECODE(ASH.SESSION_STATE, 'ON CPU', 1, 0)) "CPU", SUM(DECODE(ASH.SESSION_STATE, 'WAITING', 1, 0)) - SUM(DECODE(ASH.SESSION_STATE, 'WAITING', DECODE(ASH.WAIT_CLASS, 'USER I/O', 1, 0), 0)) "WAIT", SUM(DECODE(ASH.SESSION_STATE, 'WAITING', DECODE(ASH.WAIT_CLASS, 'USER I/O', 1, 0), 0)) "IO", SUM(DECODE(ASH.SESSION_STATE, 'ON CPU', 1, 1)) "TOTAL", DENSE_RANK() OVER(ORDER BY SUM(DECODE(ASH.SESSION_STATE, 'ON CPU', 1, 1)) DESC) RANK_ORDER WHERE SQL_ID IS NOT NULL GROUP BY ASH.INST_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, (ASH.MODULE || ' --' || ASH.ACTION || '--' || ASH.PROGRAM || '--' || ASH.CLIENT_ID || '--' || ASH.SESSION_TYPE)) ASH WHERE RANK_ORDER <= 10 ORDER BY TOTAL DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN SQL_TEXT FORMAT a500 HEADING ' SQL_TEXT ' ENTMAP OFF COLUMN SQL_EXEC_START FORMAT a140 HEADING ' SQL_EXEC_START ' ENTMAP OFF COLUMN LOGON_TIME FORMAT a140 HEADING ' LOGON_TIME ' ENTMAP OFF COLUMN monitor_types FORMAT a100 HEADING ' monitor_types ' ENTMAP OFF SET DEFINE ON WITH TMPS AS (SELECT WB.INST_ID INST_ID, WB.SID SID, WB.SERIAL#, WB.SPID, WB.OSUSER, WB.USERNAME, WA.PLAN_DEPTH, WA.PLAN_OPERATION PLAN_OPERATION, WA.PLAN_OPTIONS, WA.PLAN_PARTITION_START, WA.PLAN_PARTITION_STOP, WA.STARTS, WA.PLAN_COST, WA.PLAN_CARDINALITY, NVL(WB.SQL_ID, WA.SQL_ID) SQL_ID, WB.SQL_EXEC_START, WA.PX_SERVERS_REQUESTED, WA.PX_SERVERS_ALLOCATED, WA.PX_MAXDOP, WA.ELAPSED_TIME_S ELAPSED_TIME_S, WA.CPU_TIME CPU_TIME, WA.BUFFER_GETS, WA.PHYSICAL_READ_BYTES, WA.PHYSICAL_WRITE_BYTES, WA.USER_IO_WAIT_TIME USER_IO_WAIT_TIME, NVL((SELECT NS.SQL_TEXT FROM GV$SQLAREA NS WHERE NS.SQL_ID = WB.SQL_ID AND NS.INST_ID = WB.INST_ID),WA.SQL_TEXT) SQL_TEXT, WB.LOGON_TIME, WB.SQL_EXEC_ID, WB.EVENT, WB.BLOCKING_INSTANCE BLOCKING_INSTANCE, WB.BLOCKING_SESSION BLOCKING_SESSION, WB.BLOCKING_SESSION_SERIAL# BLOCKING_SESSION_SERIAL#, WB.TADDR, WB.SADDR, WB.LAST_CALL_ET, (WB.SESSION_INFO || ' --' || WB.SESSION_TYPE || '--' || WB.MACHINE) SESSION_INFO, (SELECT NS.EXECUTIONS FROM GV$SQLAREA NS WHERE NS.SQL_ID = WB.SQL_ID AND NS.INST_ID = WB.INST_ID) EXECUTIONS, 'SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(''' || WB.SQL_ID || ''',' || WB.SQL_CHILD_NUMBER || ',''advanced''));' SQL_PLAN, WB.ASH_COUNTS, WB.SESSION_STATE FROM (SELECT A.INST_ID, A.SID, A.PLAN_DEPTH, A.PLAN_OPERATION PLAN_OPERATION, A.PLAN_OPTIONS, A.PLAN_PARTITION_START, A.PLAN_PARTITION_STOP, A.STARTS, MAX(A.PLAN_COST) OVER(PARTITION BY A.INST_ID, A.SID, A.KEY, A.SQL_EXEC_ID, A.SQL_ID) AS PLAN_COST, MAX(A.PLAN_CARDINALITY) OVER(PARTITION BY A.INST_ID, A.SID, A.KEY, A.SQL_EXEC_ID, A.SQL_ID) AS PLAN_CARDINALITY, A.SQL_ID, A.SQL_EXEC_START, B.PX_SERVERS_REQUESTED, B.PX_SERVERS_ALLOCATED, B.PX_MAXDOP, (B.ELAPSED_TIME / 1000000) ELAPSED_TIME_S, (B.CPU_TIME / 1000000) CPU_TIME, B.BUFFER_GETS, B.PHYSICAL_READ_BYTES, B.PHYSICAL_WRITE_BYTES, (B.USER_IO_WAIT_TIME / 1000000) USER_IO_WAIT_TIME, B.SQL_TEXT SQL_TEXT, (B.MODULE || ' --' || B.ACTION || '--' || B.PROGRAM || '--' || B.PROCESS_NAME || ' --' || B.CLIENT_IDENTIFIER || '--' || B.CLIENT_INFO || ' --' || B.SERVICE_NAME) SESSION_INFO, A.SQL_EXEC_ID FROM GV$SQL_PLAN_MONITOR A, GV$SQL_MONITOR B WHERE A.SID = B.SID AND A.KEY = B.KEY AND A.INST_ID = B.INST_ID AND A.SQL_EXEC_ID = B.SQL_EXEC_ID AND A.STATUS IN ('EXECUTING', 'DONE(ERROR)') AND B.STATUS IN ('EXECUTING', 'DONE(ERROR)') AND B.PROCESS_NAME NOT LIKE 'p%') WA RIGHT OUTER JOIN (SELECT ASH.INST_ID, ASH.SESSION_ID SID, ASH.SESSION_SERIAL# SERIAL#, (SELECT PR.SPID FROM GV$PROCESS PR WHERE GVS.PADDR = PR.ADDR AND PR.INST_ID = ASH.INST_ID) SPID, ASH.SESSION_TYPE, ASH.USER_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, ASH.SQL_OPNAME, ASH.SQL_EXEC_ID, NVL(ASH.EVENT, GVS.EVENT) EVENT, ASH.SESSION_STATE, ASH.BLOCKING_SESSION, ASH.BLOCKING_SESSION_SERIAL#, ASH.BLOCKING_INST_ID BLOCKING_INSTANCE, ASH.CLIENT_ID, ASH.MACHINE, GVS.LAST_CALL_ET, GVS.TADDR, GVS.SADDR, GVS.LOGON_TIME, GVS.USERNAME, GVS.OSUSER, GVS.SQL_EXEC_START, (GVS.MODULE || ' --' || GVS.ACTION || '--' || GVS.PROGRAM || '--' || GVS.PROCESS || ' --' || GVS.CLIENT_IDENTIFIER || '--' || GVS.CLIENT_INFO || ' --' || GVS.SERVICE_NAME) SESSION_INFO, COUNT(*) ASH_COUNTS WHERE ASH.INST_ID = GVS.INST_ID AND GVS.SQL_ID = ASH.SQL_ID AND GVS.SQL_EXEC_ID = ASH.SQL_EXEC_ID AND ASH.SESSION_ID = GVS.SID AND ASH.SESSION_SERIAL# = GVS.SERIAL# AND GVS.STATUS = 'ACTIVE' AND ASH.SQL_ID IS NOT NULL GROUP BY ASH.INST_ID, ASH.SESSION_ID, ASH.SESSION_SERIAL#, ASH.SESSION_TYPE, ASH.USER_ID, ASH.SQL_ID, ASH.SQL_CHILD_NUMBER, ASH.SQL_OPNAME, ASH.SQL_EXEC_ID, NVL(ASH.EVENT, GVS.EVENT), ASH.SESSION_STATE, ASH.BLOCKING_SESSION, ASH.BLOCKING_SESSION_SERIAL#, ASH.BLOCKING_INST_ID, ASH.CLIENT_ID, ASH.MACHINE, GVS.LAST_CALL_ET, GVS.TADDR, GVS.SADDR, GVS.LOGON_TIME, GVS.USERNAME, GVS.OSUSER, GVS.PADDR, (GVS.MODULE || ' --' || GVS.ACTION || '--' || GVS.PROGRAM || '--' || GVS.PROCESS || ' --' || GVS.CLIENT_IDENTIFIER || '--' || GVS.CLIENT_INFO || ' --' || GVS.SERVICE_NAME), GVS.SQL_EXEC_START HAVING COUNT(*) > 6) WB ON (WB.SID = WA.SID AND WB.INST_ID = WA.INST_ID AND WB.SQL_ID = WA.SQL_ID AND WB.SQL_EXEC_ID = WA.SQL_EXEC_ID) ) ------------------------------------------ SELECT DISTINCT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, '[' || COUNT(*) OVER(PARTITION BY T.INST_ID, T.SID, T.SERIAL#, T.SQL_ID) || ']' MONITOR_TYPES FROM TMPS T WHERE T.PLAN_OPERATION = 'MERGE JOIN' AND T.PLAN_OPTIONS = 'CARTESIAN' AND T.USERNAME NOT IN ('SYS') UNION ALL ------------------------------------------ SQL SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, '' MONITOR_TYPES FROM TMPS T WHERE T.ELAPSED_TIME_S > &V_ELAPSED_TIME --5 * 60 * 60 AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ------------------------------------------ SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, '' MONITOR_TYPES FROM TMPS T WHERE T.PLAN_OPERATION LIKE 'PARTITION%' AND T.PLAN_OPTIONS = 'ALL' -- AND T.ELAPSED_TIME_S >= 0.5 * 60 * 60 UNION ALL ------------------------------------------ In Execution PlanCOST SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, 'In Execution PlanCOST[' || T.PLAN_COST || ']' MONITOR_TYPES FROM TMPS T WHERE T.PLAN_COST >= &v_plan_cost AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ------------------------------------------ In Execution Plan SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, 'In Execution Plan[' || T.PLAN_CARDINALITY || ']' MONITOR_TYPES FROM TMPS T WHERE T.PLAN_CARDINALITY > &v_PLAN_CARDINALITY AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ------------------------------------------ SQL SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, 'SQL[' || PX_MAXDOP || ']' MONITOR_TYPES FROM TMPS T WHERE T.PX_MAXDOP>=8 AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ------------------------------------------ SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, '[' || ROUND(D.TIME_REMAINING) || ']' MONITOR_TYPES FROM TMPS T, GV$SESSION_LONGOPS D WHERE T.SQL_EXEC_ID = D.SQL_EXEC_ID AND T.SID = D.SID AND T.SERIAL# = D.SERIAL# AND D.TIME_REMAINING > 10 AND T.INST_ID = D.INST_ID AND D.TIME_REMAINING >0 AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ------------------------------------------ SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, '[' || T.EVENT || ']' MONITOR_TYPES FROM TMPS T WHERE T.EVENT NOT IN ('db file sequential read', 'db file scattered read','db file parallel write','db file parallel read') AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ------------------------------------------ TMPTablespace Overutilization SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, 'SQLTMP[' || C.BYTES || ']Bytes' MONITOR_TYPES FROM TMPS T, (SELECT A.INST_ID, A.SESSION_ADDR, SUM(A.BLOCKS) * 8 * 1024 BYTES FROM GV$TEMPSEG_USAGE A GROUP BY A.INST_ID, A.SESSION_ADDR) C WHERE C.SESSION_ADDR = T.SADDR AND C.INST_ID = T.INST_ID AND C.BYTES > &v_tmpsize --50 * 1024 * 1024 * 1024 AND (nvl(PLAN_DEPTH,1)=1) UNION ALL ----------------------------------------- SQLUNDO,INACTIVEUNDO,SQL SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, 'SQLUNDO[' || USED_SIZE_BYTES || ']Bytes' MONITOR_TYPES FROM TMPS T, (SELECT ST.ADDR, ST.INST_ID, (ST.USED_UBLK * 8 * 1024) USED_SIZE_BYTES FROM GV$TRANSACTION ST, V$ROLLNAME R, GV$ROLLSTAT G WHERE ST.XIDUSN = R.USN AND R.USN = G.USN AND G.INST_ID = ST.INST_ID) V1 WHERE V1.ADDR = T.TADDR AND T.INST_ID = V1.INST_ID AND USED_SIZE_BYTES > 1024 -- 50 * 1024 * 1024 * 1024 UNION ALL ----------------------------------------- SQL SELECT T.INST_ID, T.SID, T.SERIAL#, T.SPID, T.OSUSER, T.USERNAME, T.EVENT, T.SESSION_STATE, T.SQL_TEXT, T.EXECUTIONS, T.ELAPSED_TIME_S, T.CPU_TIME, T.USER_IO_WAIT_TIME, T.BUFFER_GETS, T.PLAN_OPERATION, T.STARTS, T.PLAN_PARTITION_START, T.PLAN_PARTITION_STOP, T.PHYSICAL_READ_BYTES, T.PHYSICAL_WRITE_BYTES, T.BLOCKING_INSTANCE, T.BLOCKING_SESSION, T.BLOCKING_SESSION_SERIAL#, T.LAST_CALL_ET, T.SQL_ID, T.SQL_EXEC_START, T.SQL_PLAN, T.LOGON_TIME, T.ASH_COUNTS, T.SESSION_INFO, 'ASHNumber of Captures[' || T.ASH_COUNTS || ']['||SESSION_STATE||']' MONITOR_TYPES FROM TMPS T WHERE T.ASH_COUNTS>=4 AND (nvl(PLAN_DEPTH,1)=1) ORDER BY SQL_EXEC_START DESC; prompt
prompt prompt LASTIn SnapshotSQL
prompt NOTE: Excel,,, CLEAR COLUMNS COMPUTES SET DEFINE ON (SELECT round(sum(db_time) / 1000000 / 60, 2) db_time_m FROM (SELECT lead(a.value, 1, null) over(partition by B.instance_number, b.startup_time ORDER BY b.end_interval_time) - a.value db_time AND a.dbid = b.dbid AND a.instance_number = b.instance_number AND a.stat_name = 'DB time' WHERE db_time IS NOT NULL) "db_time(m)", round(nvl((sqt.elap / 1000000), to_number(null)), 2) "Elapsed Time (s)", round(nvl((sqt.cput / 1000000), to_number(null)), 2) "CPU Time (s)", round(nvl((sqt.iowait_delta / 1000000), to_number(null)), 2) "User I/O Time (s)", round(nvl((sqt.buffer_gets_delta), to_number(null)), 2) "Buffer Gets", round(nvl((sqt.disk_reads_delta), to_number(null)), 2) "Physical Reads", round(nvl((sqt.rows_processed_delta), to_number(null)), 2) "Rows Processed", round(nvl((sqt.parse_calls_delta), to_number(null)), 2) "Parse Calls", sqt.exec executions, round(DECODE(sqt.exec, 0, to_number(null), (sqt.elap / sqt.exec / 1000000)), 2) "Elapsed Time per Exec (s)", round(DECODE(sqt.exec, 0, to_number(null), (sqt.cput / sqt.exec / 1000000)), 2) "CPU per Exec (s)", round(DECODE(sqt.exec, 0, to_number(null), (sqt.iowait_delta / sqt.exec / 1000000)), 2) "UIO per Exec (s)", round(sqt.cput * 100 / sqt.elap, 2) "%CPU", round(sqt.iowait_delta * 100 / sqt.elap, 2) "%IO", round(sqt.elap * 100 / (SELECT sum(db_time) FROM (SELECT lead(a.value, 1, null) over(partition by B.instance_number, b.startup_time ORDER BY b.end_interval_time) - a.value db_time AND a.dbid = b.dbid AND a.instance_number = b.instance_number AND a.stat_name = 'DB time' WHERE db_time IS NOT NULL), 2) "elapsed/dbtime", sqt.sql_id, parsing_schema_name, (DECODE(sqt.module, null, null, sqt.module)) module, nvl((SELECT dbms_lob.substr(st.sql_text, 200, 1) WHERE st.sql_id = sqt.sql_id AND st.dbid = sqt.dbid and rownum<=1), (' SQL Text Not Available ')) sql_text FROM (SELECT sql_id, a.dbid, a.parsing_schema_name, max(module || ' --' || a.action) module, sum(elapsed_time_delta) elap, sum(cpu_time_delta) cput, sum(executions_delta) exec, SUM(a.iowait_delta) iowait_delta, sum(a.buffer_gets_delta) buffer_gets_delta, sum(a.disk_reads_delta) disk_reads_delta, sum(a.rows_processed_delta) rows_processed_delta, sum(a.parse_calls_delta) parse_calls_delta AND a.parsing_schema_name NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND a.elapsed_time_delta > 0 GROUP BY sql_id, parsing_schema_name, a.dbid) sqt ORDER BY nvl(sqt.elap, -1) desc, sqt.sql_id; prompt
prompt prompt LASTIn SnapshotSQL
CLEAR COLUMNS COMPUTES SET DEFINE ON prompt prompt ● htmlSQL
prompt prompt
prompt
prompt NOTE: gv$sql_monitor,10 CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN SQL_EXEC_START FORMAT a140 HEADING ' SQL_EXEC_START ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT d.INST_ID, d.SID, d.SESSION_SERIAL#, d.STATUS, d.USERNAME, (D.MODULE || ' --' || D.ACTION || '--' || D.PROGRAM || '--' ||D.PROCESS_NAME || '--' || D.CLIENT_IDENTIFIER || '--' ||D.CLIENT_INFO || '--' || D.SERVICE_NAME) CLIENT_INFO, d.SQL_ID, d.SQL_TEXT, d.SQL_EXEC_START, (d.ELAPSED_TIME / 1000000) ELAPSED_TIME, (d.CPU_TIME / 1000000) CPU_TIME, (d.USER_IO_WAIT_TIME / 1000000) USER_IO_WAIT_TIME, d.ERROR_NUMBER || '-' || d.ERROR_FACILITY || '-' ||d.ERROR_MESSAGE ERROR, DENSE_RANK() over(partition by INST_ID ORDER BY d.ELAPSED_TIME desc) rank_order FROM gv$sql_monitor d WHERE D.USERNAME IS NOT NULL AND d.USERNAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ) where rank_order <= 10; prompt
prompt NOTE: 11gThis item was not checked previously, now it is included.v$sql_monitor,sql prompt CLEAR COLUMNS COMPUTES SET DEFINE ON prompt NOTE: SQL: SELECT dbms_sqltune.report_sql_monitor(sql_id => &_sqlid1,type => 'text',report_level => 'all') FROM dual; prompt SELECT '
' ||dbms_sqltune.report_sql_monitor(sql_id => &_sqlid1,type => 'text',report_level => 'all') ||'' sql_monitor_results FROM DUAL; prompt prompt ● htmlsql_monitor
prompt NOTE: 11g prompt NOTE: txt,Then Save Ashtml,pingdownload.oracle.com SET DEFINE ON SET MARKUP html TABLE 'width="80%" border="1" cellspacing="0px" style="border-collapse:collapse;" ' SELECT '' report_sql_monitor FROM dual; SET MARKUP html TABLE 'width="auto" border="1" cellspacing="0px" style="border-collapse:collapse;" ' prompt
CLEAR COLUMNS COMPUTES SET DEFINE ON with force_mathces as (select l.force_matching_signature, max(l.sql_id || l.child_number) max_sql_child, dense_rank() over(order by count(*) desc) ranking, count(*) counts from v$sql l where l.force_matching_signature <> 0 and l.parsing_schema_name NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') group by l.force_matching_signature having count(*) > 10) select v.sql_id, v.sql_text, v.parsing_schema_name, fm.force_matching_signature, fm.ranking, fm.counts from force_mathces fm, v$sql v where fm.max_sql_child = (v.sql_id || v.child_number) and fm.ranking <= 50 order by fm.ranking; SELECT * FROM (SELECT a.PARSING_SCHEMA_NAME, substr(sql_text, 1, 60), count(1) counts, dense_rank() over(order by count(*) desc) ranking FROM v$sql a where a.PARSING_SCHEMA_NAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY a.PARSING_SCHEMA_NAME, substr(sql_text, 1, 60) HAVING count(1) > 10) where ranking <= 50; prompt
-- +============================================================================+ -- | | -- | <<<<< >>>>> | -- | | -- +============================================================================+ host echo " . . ." prompt prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT a.CON_ID, a.OWNER_NAME, a.FLASHBACK_ARCHIVE_NAME, a.FLASHBACK_ARCHIVE#, a.RETENTION_IN_DAYS, a.CREATE_TIME, a.LAST_PURGE_TIME, a.STATUS FROM cdb_FLASHBACK_ARCHIVE a order by a.con_id; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, d.TABLE_NAME, d.OWNER_NAME, d.FLASHBACK_ARCHIVE_NAME, d.ARCHIVE_TABLE_NAME, d.STATUS FROM cdb_FLASHBACK_ARCHIVE_TABLES d order by d.CON_ID; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, d.FLASHBACK_ARCHIVE_NAME, d.FLASHBACK_ARCHIVE#, d.TABLESPACE_NAME, d.QUOTA_IN_MB FROM cdb_FLASHBACK_ARCHIVE_TS d order by d.CON_ID; prompt
-- +============================================================================+ -- | | -- | <<<<< DG >>>>> | -- | | -- +============================================================================+ host echo " DG. . ." prompt SET DEFINE ON prompt DG( &_DGINFO2 )
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN pname FORMAT a75 HEADING '' ENTMAP OFF COLUMN instance_name_print FORMAT a45 HEADING '' ENTMAP OFF COLUMN value FORMAT a75 HEADING 'Parameter Value' ENTMAP OFF -- BREAK ON report ON pname SELECT DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.name, 0, 512) || '', '' || SUBSTR(p.name, 0, 512) || '') pname, DECODE(p.isdefault, 'FALSE', '' || i.instance_name || '', i.instance_name) instance_name_print, DECODE(p.isdefault, 'FALSE', '' || SUBSTR(p.value, 0, 512) || '', SUBSTR(p.value, 0, 512)) value FROM gv$parameter p, gv$instance i WHERE p.inst_id = i.inst_id AND p.name in ('dg_broker_start','db_name','db_unique_name','log_archive_config','log_archive_dest_1','log_archive_dest_2','log_archive_dest_state_1','log_archive_dest_state_2','log_archive_max_processes','remote_login_passwordfile','db_file_name_convert','log_file_name_convert','standby_file_management','fal_server','fal_client','dg_broker_config_file1','dg_broker_config_file2') ORDER BY p.name, i.instance_name; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN GAP_STATUS FORMAT a200 HEADING ' GAP_STATUS  ' ENTMAP OFF COLUMN OPEN_MODE FORMAT a200 HEADING ' OPEN_MODE ' ENTMAP OFF COLUMN database_role FORMAT a200 HEADING ' DATABASE_ROLE ' ENTMAP OFF COLUMN PROTECTION_MODE FORMAT a160 HEADING ' PROTECTION_MODE ' ENTMAP OFF COLUMN PROTECTION_LEVEL FORMAT a160 HEADING ' PROTECTION_LEVEL ' ENTMAP OFF SET DEFINE ON SELECT d.INST_ID, NAME, LOG_MODE, OPEN_MODE, database_role, SWITCHOVER_STATUS, db_unique_name, flashback_on, PROTECTION_MODE, PROTECTION_LEVEL, REMOTE_ARCHIVE, SWITCHOVER#, DATAGUARD_BROKER, GUARD_STATUS, SUPPLEMENTAL_LOG_DATA_MIN, SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI, FORCE_LOGGING, SUPPLEMENTAL_LOG_DATA_FK, SUPPLEMENTAL_LOG_DATA_ALL, STANDBY_BECAME_PRIMARY_SCN, FS_FAILOVER_STATUS, FS_FAILOVER_CURRENT_TARGET, FS_FAILOVER_THRESHOLD, FS_FAILOVER_OBSERVER_PRESENT, FS_FAILOVER_OBSERVER_HOST FROM gv$database d; CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN TARGET FORMAT a280 HEADING ' TARGET ' ENTMAP OFF COLUMN DATABASE_MODE FORMAT a100 HEADING ' DATABASE_MODE ' ENTMAP OFF COLUMN RECOVERY_MODE FORMAT a280 HEADING ' RECOVERY_MODE ' ENTMAP OFF COLUMN GAP_STATUS FORMAT a100 HEADING ' GAP_STATUS   ' ENTMAP OFF COLUMN OPEN_MODE FORMAT a200 HEADING ' OPEN_MODE ' ENTMAP OFF COLUMN database_role FORMAT a200 HEADING ' DATABASE_ROLE ' ENTMAP OFF COLUMN PROTECTION_MODE FORMAT a160 HEADING ' PROTECTION_MODE ' ENTMAP OFF COLUMN PROTECTION_LEVEL FORMAT a160 HEADING ' PROTECTION_LEVEL ' ENTMAP OFF COLUMN ERROR FORMAT a160 HEADING ' ERROR ' ENTMAP OFF SET DEFINE ON SELECT al.thread#, ads.dest_id, ads.DEST_NAME, (SELECT ads.TYPE || ' ' || ad.TARGET FROM v$archive_dest AD WHERE AD.DEST_ID = ADS.DEST_ID) TARGET, ADS.DATABASE_MODE, ads.STATUS, ads.error, ads.RECOVERY_MODE, ads.DB_UNIQUE_NAME, ads.DESTINATION, ads.GAP_STATUS, (SELECT MAX(sequence#) FROM v$log na WHERE na.thread# = al.thread#) Current_Seq#, MAX(sequence#) Last_Archived, max(CASE WHEN al.APPLIED = 'YES' AND ads.TYPE <> 'LOCAL' THEN al.sequence# end) APPLIED_SEQ#, (SELECT ad.applied_scn FROM v$archive_dest AD WHERE AD.DEST_ID = ADS.DEST_ID) applied_scn FROM (SELECT * FROM v$archived_log V WHERE V.resetlogs_change# = (SELECT d.RESETLOGS_CHANGE# FROM v$database d)) al, v$archive_dest_status ads WHERE al.dest_id(+) = ads.dest_id AND ads.STATUS != 'INACTIVE' GROUP BY al.thread#, ads.dest_id, ads.DEST_NAME, ads.STATUS, ads.error, ads.TYPE, ADS.DATABASE_MODE, ads.RECOVERY_MODE, ads.DB_UNIQUE_NAME, ads.DESTINATION, ads.GAP_STATUS ORDER BY al.thread#, ads.dest_id; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON col group_# format a5 col PROCESS format a8 col CLIENT_PID format a8 set line 9999 pagesize 9999 SELECT a.INST_ID, a.PROCESS, a.client_process, a.client_pid, a.STATUS, a.GROUP# group_#, a.thread#, a.SEQUENCE#, a.DELAY_MINS, a.RESETLOG_ID, c.SID, c.SERIAL#, a.PID spid, b.PNAME FROM gV$MANAGED_STANDBY a, gv$process b, gv$session c WHERE a.PID = b.SPID and b.ADDR = c.PADDR and a.INST_ID = b.INST_ID and b.INST_ID = c.INST_ID order by a.INST_ID,b.PNAME; commit; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT GROUP#, DBID db_id, THREAD#, SEQUENCE#, BYTES, USED, ARCHIVED, STATUS, FIRST_CHANGE#, NEXT_CHANGE#, LAST_CHANGE# FROM Gv$standby_log; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON prompt ● gv$dataguard_config SELECT * FROM gv$dataguard_config; prompt ● gv$dataguard_process SELECT * FROM gv$dataguard_process; prompt ● gv$dataguard_stats SELECT * FROM gv$dataguard_stats; prompt ● gv$dataguard_status SELECT * FROM v$dataguard_status a where a.TIMESTAMP >= sysdate - 1 and a.MESSAGE_NUM >= (SELECT max(MESSAGE_NUM) - 100 FROM v$dataguard_status); prompt
-- +====================================================================================================================+ -- | -- | <<<<< >>>>> | -- | | -- +====================================================================================================================+ host echo "start.... ." prompt prompt
-- +----------------------------------------------------------------------------+ -- | - USER ACCOUNTS - | -- +----------------------------------------------------------------------------+ host echo " Database Users. . ." prompt prompt Database Users
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEAD 'Username' ENTMAP OFF COLUMN account_status FORMAT a75 HEAD 'Account Status' ENTMAP OFF COLUMN expiry_date FORMAT a75 HEAD 'Expire Date' ENTMAP OFF COLUMN default_tablespace FORMAT a75 HEAD 'Default Tbs.' ENTMAP OFF COLUMN temporary_tablespace FORMAT a75 HEAD 'Temp Tbs.' ENTMAP OFF COLUMN CREATED FORMAT a75 HEAD 'CREATED On' ENTMAP OFF COLUMN profile FORMAT a75 HEAD 'Profile' ENTMAP OFF COLUMN sysdba FORMAT a75 HEAD 'SYSDBA' ENTMAP OFF COLUMN sysoper FORMAT a75 HEAD 'SYSOPER' ENTMAP OFF COLUMN is_oracle_internal_user FORMAT a25 HEAD 'is_oracle_internal_user' ENTMAP OFF SET DEFINE ON SELECT A.CON_ID,'' || A.USERNAME || '' USERNAME, DECODE(A.ACCOUNT_STATUS, 'OPEN', '
') || '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - USERS WITH DBA PRIVILEGES - | -- +----------------------------------------------------------------------------+ prompt prompt DBA
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN grantee FORMAT a70 HEADING 'Grantee' ENTMAP OFF COLUMN granted_role FORMAT a35 HEADING 'Granted Role' ENTMAP OFF COLUMN admin_option FORMAT a75 HEADING 'Admin. Option?' ENTMAP OFF COLUMN default_role FORMAT a75 HEADING 'Default Role?' ENTMAP OFF SET DEFINE ON SELECT d.CON_ID, '' || grantee || '' grantee, '
-- +----------------------------------------------------------------------------+ -- | - USERS WITH SYSDATA - | -- +----------------------------------------------------------------------------+ prompt prompt SYS
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT * FROM v$pwfile_users a order by a.CON_ID; prompt
-- +----------------------------------------------------------------------------+ -- | - ROLES - | -- +----------------------------------------------------------------------------+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON COLUMN role FORMAT a70 HEAD 'Role Name' ENTMAP OFF COLUMN grantee FORMAT a35 HEAD 'Grantee' ENTMAP OFF COLUMN admin_option FORMAT a75 HEAD 'Admin Option?' ENTMAP OFF COLUMN default_role FORMAT a75 HEAD 'Default Role?' ENTMAP OFF -- BREAK ON role SELECT A.CON_ID,'' || b.role || '' role, a.grantee grantee, DECODE(a.admin_option, null, '
', 'YES', '
', 'YES', '
-- +----------------------------------------------------------------------------+ -- | - DEFAULT PASSWORDS - | -- +----------------------------------------------------------------------------+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON COLUMN username HEADING 'Username' ENTMAP OFF COLUMN account_status FORMAT a75 HEADING 'Account Status' ENTMAP OFF SELECT d.CON_ID, '' || username || '' username, DECODE(account_status, 'OPEN', '
prompt NOTE: ,UNDO CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT D.CON_ID,d.owner, round(sum(bytes)/1024/1024,2) sizes_M FROM CDB_segments d WHERE d.segment_type NOT LIKE '%UNDO%' AND not exists (SELECT 1 FROM CDB_recyclebin nb WHERE nb.owner = d.owner AND nb.object_name = d.segment_name AND NB.CON_ID=D.CON_ID) GROUP BY D.CON_ID, d.owner ORDER BY D.CON_ID, sum(bytes) DESC ; prompt
prompt prompt Failed Login Users (Past Week)
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT * FROM ( SELECT a.dbid, a.sessionid, a.process#, a.entryid, a.userid, (SELECT na.lcount FROM sys.user$ na WHERE na.name=a.userid) lcount, a.userhost, a.terminal, a.action#, a.returncode, a.comment$text, a.spare1, a.ntimestamp#+8/24 login_time FROM sys.aud$ a WHERE a.returncode = 1017 AND a.ntimestamp#+8/24 >=sysdate-7 ORDER BY a.ntimestamp# desc) WHERE ROWNUM <=100; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT DP.CON_ID, DP.PROFILE, DP.RESOURCE_NAME, DP.RESOURCE_TYPE, DP.LIMIT, listagg(DU.USERNAME,',') within group(order by du.username) USERNAMES FROM CDB_PROFILES DP, CDB_USERS DU WHERE DP.PROFILE = DU.PROFILE AND DP.CON_ID=DU.CON_ID GROUP BY DP.PROFILE, DP.RESOURCE_NAME, DP.RESOURCE_TYPE, DP.LIMIT,DP.CON_ID ORDER BY DP.CON_ID,DP.PROFILE; prompt
-- +----------------------------------------------------------------------------+ -- | - Users with SYSTEM as Default Tablespace - | -- +----------------------------------------------------------------------------+ host echo " . . ." prompt prompt
prompt
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN default_tablespace FORMAT a125 HEADING 'Default Tablespace' ENTMAP OFF COLUMN temporary_tablespace FORMAT a125 HEADING 'Temporary Tablespace' ENTMAP OFF COLUMN CREATED FORMAT a75 HEADING 'CREATED' ENTMAP OFF COLUMN account_status FORMAT a75 HEADING 'Account Status' ENTMAP OFF SELECT d.CON_ID, '' || username || '' username, '
-- +----------------------------------------------------------------------------+ -- | - Users with SYSTEM as Temporary Tablespace - | -- +----------------------------------------------------------------------------+ prompt prompt SYSTEM
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a75 HEADING 'Username' ENTMAP OFF COLUMN default_tablespace FORMAT a125 HEADING 'Default Tablespace' ENTMAP OFF COLUMN temporary_tablespace FORMAT a125 HEADING 'Temporary Tablespace' ENTMAP OFF COLUMN CREATED FORMAT a75 HEADING 'CREATED' ENTMAP OFF COLUMN account_status FORMAT a75 HEADING 'Account Status' ENTMAP OFF SELECT d.CON_ID, '' || username || '' username, '
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.NAME,d.VALUE,d.ISDEFAULT,d.DESCRIPTION FROM v$parameter d WHERE d.NAME='audit_trail'; prompt
SELECT d.CON_ID, d.OWNER, d.TABLE_NAME, d.TABLESPACE_NAME, d.PARTITIONED, d.NUM_ROWS, d.LAST_ANALYZED, (SELECT sum(ds.BYTES) / 1024 / 1024 FROM cdb_segments ds WHERE ds.segment_name = d.TABLE_NAME and ds.CON_ID=d.CON_ID) tb_size_m, (SELECT sum(ds.BYTES) / 1024 / 1024 FROM cdb_segments ds, cdb_indexes di WHERE ds.segment_name = di.index_name AND di.table_name = d.TABLE_NAME and ds.CON_ID=di.CON_ID and ds.CON_ID=d.CON_ID) index_size_m FROM cdb_tables d WHERE d.TABLE_NAME = 'AUD$' order by d.CON_ID; prompt SET MARKUP html TABLE 'width="80%" border="1" cellspacing="0px" style="border-collapse:collapse;" ' SELECT '' AUD$ FROM dual; SET MARKUP html TABLE 'width="auto" border="1" cellspacing="0px" style="border-collapse:collapse;" ' prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, action_name, count(*) cnt FROM cdb_audit_trail d GROUP BY d.CON_ID, action_name order by d.CON_ID, action_name; prompt
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, '
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN segment_name FORMAT a125 HEADING 'Segment Name' ENTMAP OFF COLUMN segment_type FORMAT a75 HEADING 'Type' ENTMAP OFF COLUMN tablespace_name FORMAT a125 HEADING 'Tablespace' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Bytes|Alloc' ENTMAP OFF COLUMN extents FORMAT 999,999,999,999,999 HEADING 'Extents' ENTMAP OFF COLUMN max_extents FORMAT 999,999,999,999,999 HEADING 'Max|Ext' ENTMAP OFF COLUMN initial_extent FORMAT 999,999,999,999,999 HEADING 'Initial|Ext' ENTMAP OFF COLUMN next_extent FORMAT 999,999,999,999,999 HEADING 'Next|Ext' ENTMAP OFF COLUMN pct_increase FORMAT 999,999,999,999,999 HEADING 'Pct|Inc' ENTMAP OFF -- BREAK ON report ON owner COMPUTE count LABEL 'Total Count: ' OF segment_name ON report COMPUTE sum LABEL 'Total Bytes: ' OF bytes ON report SELECT d.CON_ID, '
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, table_name, owner, tablespace_name FROM cdb_tables d WHERE tablespace_name in ('SYSTEM') AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, d.owner index_owner, index_name, d.tablespace_name index_ts_name, d.table_owner, d.table_name, d.table_type, nb.TABLESPACE_NAME table_ts_name, nb.PARTITIONED table_PARTITIONED, nb.TEMPORARY table_TEMPORARY FROM cdb_indexes d, cdb_tables nb WHERE nb.OWNER = d.table_owner AND d.table_name = nb.TABLE_NAME and d.CON_ID=nb.CON_ID and d.tablespace_name in ('SYSTEM') AND d.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG'); prompt
-- +----------------------------------------------------------------------------+ -- | - OBJECT SUMMARY - | -- +----------------------------------------------------------------------------+ host echo " . . ." prompt prompt
prompt
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a60 HEADING 'Owner' ENTMAP OFF COLUMN object_type FORMAT a25 HEADING 'Object Type' ENTMAP OFF COLUMN obj_count FORMAT 999,999,999,999 HEADING 'Object Count' ENTMAP OFF -- BREAK ON report ON owner SKIP 2 -- compute sum label """ of obj_count on owner -- compute sum label 'Grand Total: ' of obj_count on report COMPUTE sum LABEL 'Total: ' OF obj_count ON report SELECT d.CON_ID, '' || owner || '' owner, object_type object_type, count(*) obj_count FROM cdb_objects d WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY d.CON_ID,owner, object_type ORDER BY d.CON_ID,owner, object_type; prompt
-- +----------------------------------------------------------------------------+ -- | - SEGMENT SUMMARY - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a50 HEADING 'Owner' ENTMAP OFF COLUMN segment_type FORMAT a25 HEADING 'Segment Type' ENTMAP OFF COLUMN seg_count FORMAT 999,999,999,999 HEADING 'Segment Count' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in Bytes)' ENTMAP OFF -- BREAK ON report ON owner SKIP 2 -- COMPUTE sum LABEL """ OF seg_count bytes ON owner COMPUTE sum LABEL 'Total: ' OF seg_count bytes ON report SELECT d.CON_ID, '' || owner || '' owner, segment_type segment_type, count(*) seg_count, sum(bytes) bytes FROM cdb_segments d WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY d.CON_ID,owner, segment_type ORDER BY d.CON_ID,owner, segment_type; prompt
-- +----------------------------------------------------------------------------+ -- | - TOP 10 SEGMENTS (BY SIZE) - | -- +----------------------------------------------------------------------------+ host echo " 10segments. . . ." prompt prompt 10segments
prompt ● CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner HEADING 'Owner' ENTMAP OFF COLUMN segment_name HEADING 'Segment Name' ENTMAP OFF COLUMN partition_name HEADING 'Partition Name' ENTMAP OFF COLUMN segment_type HEADING 'Segment Type' ENTMAP OFF COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP OFF COLUMN extents FORMAT 999,999,999,999,999,999 HEADING 'Extents' ENTMAP OFF -- BREAK ON report COMPUTE sum LABEL 'Total: ' OF bytes extents ON report SELECT a.con_id, a.owner, a.segment_name, a.partition_name, a.segment_type, a.tablespace_name, a.bytes, (bytes) segments_size, a.extents FROM (SELECT b.CON_ID, b.owner, b.segment_name, b.partition_name, b.segment_type, b.tablespace_name, b.bytes, b.extents FROM cdb_segments b WHERE b.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ORDER BY b.bytes desc) a WHERE ROWNUM <= 20; prompt ● CLEAR COLUMNS COMPUTES SET DEFINE OFF -- BREAK ON report COMPUTE sum LABEL 'Total: ' OF object_size_M ON report SELECT * FROM (SELECT b.CON_ID, owner, segment_name, segment_type, b.tablespace_name, round(sum(bytes) / 1024 / 1024) object_size_M FROM cdb_segments b WHERE b.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY b.CON_ID,owner, segment_name, segment_type,b.tablespace_name ORDER BY object_size_M desc) WHERE ROWNUM <= 10; prompt ● Tablespace-based analysis, showing top3 CLEAR COLUMNS COMPUTES SET DEFINE OFF -- BREAK ON report COMPUTE sum LABEL 'Total: ' OF size_m ON report SELECT CON_ID,a.owner, a.segment_name, a.partition_name, a.segment_type, a.tablespace_name, round(a.bytes/1024/1024,2) size_m, (bytes) segments_size, a.extents FROM (SELECT b.CON_ID, b.owner, b.segment_name, b.partition_name, b.segment_type, b.tablespace_name, b.bytes, b.extents, DENSE_RANK() over(partition by b.tablespace_name ORDER BY b.bytes desc) rank_order FROM cdb_segments b WHERE b.BYTES > 10*1024*1024 AND b.tablespace_name NOT LIKE 'UNDO%' AND b.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND b.segment_name not in (SELECT nr.object_name FROM cdb_recyclebin nr) ) a WHERE rank_order <= 3 ORDER BY CON_ID,a.tablespace_name, a.bytes desc, a.owner; prompt
-- +----------------------------------------------------------------------------+ -- | - TOP 10 SEGMENTS (BY EXTENTS) - | -- +----------------------------------------------------------------------------+ host echo " 10segments. . . ." prompt prompt 10segments
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner HEADING 'Owner' ENTMAP OFF COLUMN segment_name HEADING 'Segment Name' ENTMAP OFF COLUMN partition_name HEADING 'Partition Name' ENTMAP OFF COLUMN segment_type HEADING 'Segment Type' ENTMAP OFF COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP OFF COLUMN extents FORMAT 999,999,999,999,999,999 HEADING 'Extents' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP OFF -- BREAK ON report COMPUTE sum LABEL 'Total: ' OF extents bytes ON report SELECT a.con_id, a.owner, a.segment_name, a.partition_name, a.segment_type, a.tablespace_name, a.extents, a.bytes FROM (select b.CON_ID, b.owner, b.segment_name, b.partition_name, b.segment_type, b.tablespace_name, b.bytes, b.extents from cdb_segments b WHERE b.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') order by b.extents desc) a WHERE ROWNUM <= 10; prompt
-- +----------------------------------------------------------------------------+ -- | - LOB SEGMENTS - | -- +----------------------------------------------------------------------------+ host echo " LOB. . . ." prompt prompt LOB
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) ,SELECT top 100 rows CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a85 HEADING 'Owner' ENTMAP OFF COLUMN table_name FORMAT a75 HEADING 'Table Name' ENTMAP OFF COLUMN column_name FORMAT a75 HEADING 'Column Name' ENTMAP OFF COLUMN segment_name FORMAT a125 HEADING 'LOB Segment Name' ENTMAP OFF COLUMN tablespace_name FORMAT a75 HEADING 'Tablespace Name' ENTMAP OFF COLUMN lob_segment_bytes FORMAT a75 HEADING 'Segment Size' ENTMAP OFF COLUMN index_name FORMAT a125 HEADING 'LOB Index Name' ENTMAP OFF COLUMN in_row FORMAT a75 HEADING 'In Row?' ENTMAP OFF -- BREAK ON report ON owner ON table_name SELECT * FROM (SELECT l.CON_ID, '
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt Segments that cannot extend because of MAXEXTENTS or not enough space CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP OFF COLUMN segment_name HEADING 'Segment Name' ENTMAP OFF COLUMN segment_type HEADING 'Segment Type' ENTMAP OFF COLUMN next_extent FORMAT 999,999,999,999,999 HEADING 'Next Extent' ENTMAP OFF COLUMN max FORMAT 999,999,999,999,999 HEADING 'Max. Piece Size' ENTMAP OFF COLUMN sum FORMAT 999,999,999,999,999 HEADING 'Sum of Bytes' ENTMAP OFF COLUMN extents FORMAT 999,999,999,999,999 HEADING 'Num. of Extents' ENTMAP OFF COLUMN max_extents FORMAT 999,999,999,999,999 HEADING 'Max Extents' ENTMAP OFF -- BREAK ON report ON owner SELECT ds.con_id, '
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ prompt prompt 1/2
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN tablespace_name FORMAT a30 HEADING 'Tablespace name' ENTMAP OFF COLUMN segment_name FORMAT a30 HEADING 'Segment Name' ENTMAP OFF COLUMN segment_type FORMAT a20 HEADING 'Segment Type' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP OFF COLUMN next_extent FORMAT 999,999,999,999,999 HEADING 'Next Extent Size' ENTMAP OFF COLUMN pct_increase HEADING '% Increase' ENTMAP OFF COLUMN extents FORMAT 999,999,999,999,999 HEADING 'Num. of Extents' ENTMAP OFF COLUMN max_extents FORMAT 999,999,999,999,999 HEADING 'Max Extents' ENTMAP OFF COLUMN pct_util FORMAT a35 HEADING '% Utilized' ENTMAP OFF SELECT b.CON_ID, owner, tablespace_name, segment_name, segment_type, bytes, next_extent, pct_increase, extents, max_extents, '
-- +============================================================================+ -- | | -- | <<<<< UNDO Segments >>>>> | -- | | -- +============================================================================+ host echo " Undo . . . ." prompt prompt
prompt undo_retention is specified in minutes CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a95 HEADING 'Instance_Name' ENTMAP OFF COLUMN thread_number_print FORMAT a95 HEADING 'Thread Number' ENTMAP OFF COLUMN name FORMAT a125 HEADING 'Name' ENTMAP OFF COLUMN value HEADING 'Value' ENTMAP OFF -- BREAK ON report ON instance_name_print ON thread_number_print SELECT '
---------------------------------------------------------------------------------------------------------------------------------------- -- +----------------------------------------------------------------------------+ -- | - UNDO SEGMENTS - | -- +----------------------------------------------------------------------------+ prompt prompt ● Details
prompt ● UNDO, CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name FORMAT a75 HEADING 'Instance_Name' ENTMAP OFF COLUMN tablespace FORMAT a85 HEADING 'Tablspace' ENTMAP OFF COLUMN roll_name HEADING 'UNDO Segment Name' ENTMAP OFF COLUMN in_extents HEADING 'Init/Next Extents' ENTMAP OFF COLUMN m_extents HEADING 'Min/Max Extents' ENTMAP OFF COLUMN status HEADING 'Status' ENTMAP OFF COLUMN wraps FORMAT 999,999,999 HEADING 'Wraps' ENTMAP OFF COLUMN shrinks FORMAT 999,999,999 HEADING 'Shrinks' ENTMAP OFF COLUMN opt FORMAT 999,999,999,999 HEADING 'Opt. Size' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999 HEADING 'Bytes' ENTMAP OFF COLUMN extents FORMAT 999,999,999 HEADING 'Extents' ENTMAP OFF CLEAR COMPUTES -- BREAK ON report ON instance_name ON tablespace -- COMPUTE sum LABEL 'Total:' OF bytes extents shrinks wraps ON report --SELECT * FROM v$rollname; --SELECT * FROM dba_rollback_segs d ORDER BY d.instance_num; SELECT a.CON_ID, '
') || '
-- +----------------------------------------------------------------------------+ -- | - TABLESPACE TO OWNER - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN tablespace_name FORMAT a75 HEADING 'Tablespace Name' ENTMAP OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN segment_type FORMAT a75 HEADING 'Segment Type' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in Bytes)' ENTMAP OFF COLUMN seg_count FORMAT 999,999,999,999 HEADING 'Segment Count' ENTMAP OFF -- BREAK ON report ON tablespace_name COMPUTE sum LABEL 'Total: ' of seg_count bytes ON report SELECT d.CON_ID, '' || tablespace_name || '' tablespace_name, '
prompt
-- +----------------------------------------------------------------------------+
-- | - -
-- +----------------------------------------------------------------------------+
prompt
prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - - -- +----------------------------------------------------------------------------+ prompt prompt
prompt NOTE: Tables must have statistics gathered CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner HEADING 'Owner' ENTMAP OFF COLUMN table_name HEADING 'Table Name' ENTMAP OFF COLUMN partition_name HEADING 'Partition Name' ENTMAP OFF COLUMN num_rows FORMAT 999,999,999,999,999 HEADING 'Total Rows' ENTMAP OFF COLUMN pct_chained_rows FORMAT a65 HEADING '% Chained Rows' ENTMAP OFF COLUMN avg_row_length FORMAT 999,999,999,999,999 HEADING 'Avg Row Length' ENTMAP OFF SELECT con_id, owner owner, table_name table_name, '' partition_name, num_rows num_rows, '
-- +----------------------------------------------------------------------------+ -- | - 10WTables Without Primary Key - -- +----------------------------------------------------------------------------+ prompt prompt 10WTables Without Primary Key
prompt NOTE: Tables must have statistics gathered CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, D.OWNER, count(1) counts FROM cdb_TABLES d WHERE not exists (SELECT 1 FROM cdb_constraints dc WHERE dc.constraint_type = 'P' AND dc.table_name = d.TABLE_NAME AND dc.owner = d.OWNER and dc.CON_ID=d.CON_ID) AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND D.NUM_ROWS >= 100000 GROUP BY d.CON_ID,D.OWNER ORDER BY d.CON_ID,counts desc; prompt prompt NOTE: 50 COLUMN TEMPORARY format a10 HEADING 'TEMPORARY' ENTMAP OFF COLUMN PARTITIONED format a20 HEADING 'PARTITIONED' ENTMAP OFF SELECT * FROM ( SELECT d.con_id, D.OWNER, D.TABLE_NAME, D.TEMPORARY, D.PARTITIONED,/* D.RESULT_CACHE,*/ D.TABLESPACE_NAME, D.LOGGING, D.ROW_MOVEMENT, D.NUM_ROWS, DENSE_RANK() over(ORDER BY D.NUM_ROWS desc) rank FROM cdb_TABLES d WHERE not exists (SELECT 1 FROM cdb_constraints dc WHERE dc.constraint_type = 'P' AND dc.table_name = d.TABLE_NAME AND dc.owner = d.OWNER and dc.CON_ID=d.CON_ID) AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND D.NUM_ROWS >= 100000) WHERE rank<=50 ORDER BY con_id, OWNER, TABLE_NAME, NUM_ROWS DESC ; prompt
-- +----------------------------------------------------------------------------+ -- | - - -- +----------------------------------------------------------------------------+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT t.con_id, t.owner, t.table_name, t.partition_name, t.tablespace_name, t.logging, t.last_analyzed, t.sizes sizes_m FROM ( ---------------------------------- SELECT d.con_id, D.owner, D.table_name, '' partition_name, D.tablespace_name, D.logging, D.last_analyzed, b.sizes FROM cdb_tables d, (SELECT nb.CON_ID, NB.owner, NB.segment_name, SUM(NB.BYTES) / 1024 / 1024 SIZES FROM cdb_SEGMENTS NB WHERE NB.partition_name IS NULL AND nb.segment_type = 'TABLE' AND nb.BYTES / nb.initial_extent > 1.1 AND nb.owner NOT IN ('SYS', 'SYSTEM') AND nb.tablespace_name NOT IN ('SYSTEM', 'SYSAUX') GROUP BY nb.CON_ID, NB.owner, NB.segment_name) B WHERE B.segment_name = D.table_name AND D.owner = B.owner and d.CON_ID = b.con_id AND d.partitioned = 'NO' AND D.owner NOT IN ('SYS', 'SYSTEM') AND D.tablespace_name NOT IN ('SYSTEM', 'SYSAUX') AND D.num_rows = 0 AND B.SIZES > 10 UNION ALL ------------------------------------------------------------ SELECT d.con_id, D.Table_Owner, D.table_name, d.partition_name, D.tablespace_name, D.logging, D.last_analyzed, b.sizes FROM cdb_TAB_PARTITIONS d, (SELECT nb.con_id, NB.owner, NB.segment_name, nb.partition_name, SUM(NB.BYTES) / 1024 / 1024 SIZES FROM cdb_SEGMENTS NB WHERE NB.partition_name IS NOT NULL AND nb.segment_type = 'TABLE PARTITION' AND nb.BYTES / nb.initial_extent > 1.1 AND nb.owner NOT IN ('SYS', 'SYSTEM') AND nb.tablespace_name NOT IN ('SYSTEM', 'SYSAUX') GROUP BY nb.con_id, NB.owner, NB.segment_name, nb.partition_name) B WHERE B.segment_name = D.table_name AND D.Table_Owner = B.owner AND d.partition_name = b.partition_name and b.con_id = d.con_id AND D.TABLE_OWNER NOT IN ('SYS', 'SYSTEM') AND D.tablespace_name NOT IN ('SYSTEM', 'SYSAUX') AND D.num_rows = 0 AND B.SIZES > 10) t WHERE t.table_name NOT LIKE '%TMP%' AND t.table_name NOT LIKE '%TEMP%'; prompt
host echo " . . ." prompt prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.con_id, owner, segment_name, segment_type, ROUND(sum(bytes)/1024/1024/1024,3) object_size_G FROM cdb_segments d where segment_type = 'TABLE' AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') group by d.con_id, owner, segment_name, segment_type having sum(bytes) / 1024 / 1024 / 1024 >= 10 ORDER BY d.con_id,object_size_G desc; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM (SELECT d.CON_ID, table_owner, table_name, count(*) cnt FROM cdb_tab_partitions d WHERE table_owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY d.CON_ID,table_owner, table_name ORDER BY cnt desc) where ROWNUM <= 10; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, table_owner, table_name, count(*) cnt FROM cdb_tab_partitions d WHERE table_owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') having count(*) >= 100 group by d.CON_ID,table_owner, table_name ORDER BY cnt desc; prompt
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a85 HEADING 'Owner' ENTMAP OFF COLUMN object_name FORMAT a30 HEADING 'Object Name' ENTMAP OFF COLUMN object_type FORMAT a20 HEADING 'Object Type' ENTMAP OFF COLUMN status FORMAT a75 HEADING 'Status' ENTMAP OFF -- BREAK ON report ON owner -- COMPUTE count LABEL 'Grand Total: ' OF object_name ON report SELECT d.CON_ID, d.OWNER, count(*) cnt FROM cdb_objects d WHERE owner not in ('PUBLIC') AND status <> 'VALID' group by d.con_id,d.OWNER ORDER BY con_id, owner; prompt 200 SELECT d.CON_ID, '
-- +----------------------------------------------------------------------------+ -- | - PROCEDURAL OBJECT ERRORS - | -- +----------------------------------------------------------------------------+ prompt prompt ● Procedural Object Errors
prompt All records FROM cdb_ERRORS CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a85 HEAD 'Schema' ENTMAP OFF COLUMN name FORMAT a30 HEAD 'Object Name' ENTMAP OFF COLUMN type FORMAT a15 HEAD 'Object Type' ENTMAP OFF COLUMN sequence FORMAT 999,999 HEAD 'Sequence' ENTMAP OFF COLUMN line FORMAT 999,999 HEAD 'Line' ENTMAP OFF COLUMN position FORMAT 999,999 HEAD 'Position' ENTMAP OFF COLUMN text HEAD 'Text' ENTMAP OFF SET DEFINE ON -- BREAK ON report ON owner SELECT d.CON_ID, d.owner, d.name, d.type, count(1) cnt FROM cdb_errors d WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY d.CON_ID, d.owner, d.name, d.type ORDER BY d.CON_ID,d.owner, d.name, d.type, cnt desc; prompt SELECT d.con_id, '
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT t.CON_ID, t.owner index_owner, t.index_name, t.table_owner, t.table_name, blevel, t.num_rows, t.leaf_blocks, t.distinct_keys FROM cdb_indexes t WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND status = 'UNUSABLE' order by t.CON_ID,t.OWNER,t.INDEX_NAME; prompt
prompt prompt Invalid Partition Index
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT t2.CON_ID, t2.owner, t1.blevel, t1.leaf_blocks, t1.INDEX_NAME, t2.table_name, t1.PARTITION_NAME, t1.STATUS FROM cdb_ind_partitions t1, cdb_indexes t2 where t1.index_name = t2.index_name and t1.CON_ID=t2.CON_ID AND t1.STATUS = 'UNUSABLE' AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') order by t2.CON_ID,t2.OWNER ; prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, '
host echo " . . ." prompt prompt
prompt
prompt NOTE: 50 CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM (SELECT d.CON_ID, owner, table_name, count(*) index_count FROM cdb_indexes d WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY d.CON_ID, owner, table_name having count(*) > 5 ORDER BY con_id, index_count desc) WHERE ROWNUM <= 100; prompt
prompt ● 2G
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, owner, segment_name, round(bytes / 1024 / 1024 / 1024, 3) size_g, blocks, tablespace_name FROM cdb_segments d WHERE segment_type = 'TABLE' AND segment_name NOT IN (SELECT table_name FROM cdb_indexes) AND bytes / 1024 / 1024 / 1024 >= 2 and owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ORDER BY d.CON_ID, bytes DESC; prompt prompt ● 2GB
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.con_id, owner, segment_name, round(SUM(bytes) / 1024 / 1024 / 1024, 3) size_g, SUM(blocks) FROM cdb_segments d WHERE segment_type = 'TABLE PARTITION' AND segment_name NOT IN (SELECT table_name FROM cdb_indexes) and owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY d.CON_ID, owner, segment_name HAVING SUM(bytes) / 1024 / 1024 / 1024 >= 2 ORDER BY d.CON_ID,SUM(bytes) DESC; prompt
prompt NOTE: Top100 CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM (SELECT d.CON_ID, d.TABLE_OWNER, table_name, trunc(count(distinct(column_name)) / count(*), 2) cross_idx_rate FROM cdb_ind_columns d WHERE table_name NOT LIKE 'BIN$%' and TABLE_OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY con_id, TABLE_OWNER, table_name having count(distinct(column_name)) / count(*) < 1 ORDER BY con_id,cross_idx_rate desc) WHERE ROWNUM <= 100; prompt
prompt NOTE: Top100 CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM (SELECT t.CON_ID, t.owner, t.table_name, t.index_name, t.index_type, t.status, t.blevel, t.leaf_blocks, DENSE_RANK() over(partition by t.index_type ORDER BY t.leaf_blocks desc) rn FROM cdb_indexes t WHERE index_type in ('BITMAP', 'FUNCTION-BASED NORMAL') AND owner not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND t.leaf_blocks > 0) v WHERE rn <= 100 ORDER BY v.CON_ID, v.owner, v.table_name, rn; prompt
host echo " . . . ." prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT con_id, owner, table_name, constraint_name, cname1 || nvl2(cname2, ',' || cname2, null) || nvl2(cname3, ',' || cname3, null) || nvl2(cname4, ',' || cname4, null) || nvl2(cname5, ',' || cname5, null) || nvl2(cname6, ',' || cname6, null) || nvl2(cname7, ',' || cname7, null) || nvl2(cname8, ',' || cname8, null) columns FROM (SELECT b.con_id, b.owner, b.table_name, b.constraint_name, max(DECODE(position, 1, column_name, null)) cname1, max(DECODE(position, 2, column_name, null)) cname2, max(DECODE(position, 3, column_name, null)) cname3, max(DECODE(position, 4, column_name, null)) cname4, max(DECODE(position, 5, column_name, null)) cname5, max(DECODE(position, 6, column_name, null)) cname6, max(DECODE(position, 7, column_name, null)) cname7, max(DECODE(position, 8, column_name, null)) cname8, count(*) col_cnt FROM (SELECT nc.con_id, substr(table_name, 1, 30) table_name, substr(constraint_name, 1, 30) constraint_name, substr(column_name, 1, 30) column_name, position FROM cdb_cons_columns nc WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ) a, cdb_constraints b WHERE a.constraint_name = b.constraint_name and a.con_id=b.con_id AND b.constraint_type = 'R' AND b.owner not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY b.con_id, b.owner, b.table_name, b.constraint_name) cons WHERE col_cnt > ALL (SELECT count(*) FROM cdb_ind_columns i WHERE i.table_name = cons.table_name AND i.column_name in (cname1, cname2, cname3, cname4, cname5, cname6, cname7, cname8) AND i.column_position <= cons.col_cnt AND i.index_owner not IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY con_id,i.index_name) order by con_id; prompt
host echo " . . . ." prompt prompt
prompt NOTE: 1M,,TOP50 CLEAR COLUMNS COMPUTES SET DEFINE OFF --COLUMN count_index_cols FORMAT a75 HEADING '' ENTMAP OFF COLUMN CREATED FORMAT a140 HEADING ' CREATED ' ENTMAP OFF COLUMN min_date FORMAT a140 HEADING ' min_date ' ENTMAP OFF COLUMN max_date FORMAT a140 HEADING ' max_date ' ENTMAP OFF SET DEFINE ON SELECT CON_ID, TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME, CREATED, INDEX_TYPE, INDEX_MB, COUNT_INDEX_COLS, MIN_DATE, MAX_DATE FROM (WITH TMP1 AS (SELECT I.CON_ID, I.OWNER INDEX_OWNER, I.TABLE_OWNER, TABLE_NAME, INDEX_NAME, INDEX_TYPE, (SELECT NB.CREATED FROM CDB_OBJECTS NB WHERE NB.OWNER = I.OWNER AND NB.OBJECT_NAME = I.INDEX_NAME AND NB.CON_ID=I.CON_ID AND NB.SUBOBJECT_NAME IS NULL AND NB.OBJECT_TYPE = 'INDEX') CREATED, ROUND(SUM(S.BYTES) / 1024 / 1024, 2) INDEX_MB, (SELECT COUNT(1) FROM CDB_IND_COLUMNS DIC WHERE DIC.INDEX_NAME = I.INDEX_NAME AND DIC.TABLE_NAME = I.TABLE_NAME AND DIC.INDEX_OWNER = I.OWNER AND DIC.CON_ID=I.CON_ID) COUNT_INDEX_COLS, DENSE_RANK() OVER(ORDER BY SUM(S.BYTES) DESC) RANK_ORDER FROM CDB_SEGMENTS S, CDB_INDEXES I WHERE I.INDEX_NAME = S.SEGMENT_NAME AND S.CON_ID=I.CON_ID AND S.SEGMENT_TYPE LIKE '%INDEX%' AND I.OWNER = S.OWNER AND S.OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY I.CON_ID, I.OWNER, I.TABLE_OWNER, TABLE_NAME, INDEX_NAME, INDEX_TYPE HAVING SUM(S.BYTES) > 1024 * 1024), TMP2 AS (SELECT CON_ID, INDEX_OWNER,INDEX_NAME, PLAN_OPERATION, (SELECT MIN(TO_CHAR(NB.BEGIN_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS')) FROM CDB_HIST_SNAPSHOT NB (SELECT MAX(TO_CHAR(NB.END_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS')) FROM CDB_HIST_SNAPSHOT NB COUNTS FROM (SELECT D.CON_ID, D.OBJECT_OWNER INDEX_OWNER, D.OBJECT_NAME INDEX_NAME, D.OPERATION || ' ' || D.OPTIONS PLAN_OPERATION, COUNT(1) COUNTS FROM CDB_HIST_SQL_PLAN D, CDB_HIST_SQLSTAT H WHERE D.OBJECT_OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND D.OPERATION LIKE '%INDEX%' AND D.SQL_ID =H.SQL_ID AND D.CON_ID=H.CON_ID GROUP BY D.CON_ID, D.OBJECT_OWNER,D.OBJECT_NAME,D.OPERATION,D.OPTIONS) V) SELECT A.CON_ID, A.TABLE_OWNER, A.TABLE_NAME, A.INDEX_OWNER, A.INDEX_NAME, A.CREATED, A.INDEX_TYPE, A.INDEX_MB, COUNT_INDEX_COLS, CASE WHEN MIN_DATE IS NULL THEN (SELECT MIN(TO_CHAR(NB.BEGIN_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS')) FROM CDB_HIST_SNAPSHOT NB) ELSE MIN_DATE END AS MIN_DATE, CASE WHEN MAX_DATE IS NULL THEN (SELECT MAX(TO_CHAR(NB.BEGIN_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS')) FROM CDB_HIST_SNAPSHOT NB) ELSE MAX_DATE END AS MAX_DATE, PLAN_OPERATION, DENSE_RANK() OVER(ORDER BY INDEX_MB DESC) RANK_ORDER2 FROM TMP1 A LEFT OUTER JOIN TMP2 B ON (A.INDEX_OWNER = B.INDEX_OWNER AND A.INDEX_NAME = B.INDEX_NAME AND A.CON_ID=B.CON_ID) AND RANK_ORDER <= 50) WHERE PLAN_OPERATION IS NULL AND RANK_ORDER2 <= 50 ORDER BY CON_ID,TABLE_OWNER, TABLE_NAME, INDEX_MB DESC; prompt
host echo " 3. . . ." prompt prompt 3[Next Item]
prompt NOTE: 3,3 CLEAR COLUMNS COMPUTES SET DEFINE OFF --COLUMN IND_COLS_COUNT FORMAT a75 HEADING '' ENTMAP OFF COLUMN PARTITIONED FORMAT a11 HEADING 'PARTITIONED' ENTMAP OFF COLUMN IS_PRIMARY_KEY FORMAT a15 HEADING 'IS_PRIMARY_KEY' ENTMAP OFF COLUMN LAST_ANALYZED FORMAT a140 HEADING ' LAST_ANALYZED ' ENTMAP OFF COLUMN INDEX_CREATE FORMAT a140 HEADING ' INDEX_CREATE ' ENTMAP OFF SET DEFINE ON SELECT TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME, INDEX_TYPE, UNIQUENESS, (SELECT DECODE(nb.constraint_type, 'P', 'YES') FROM cdb_constraints nb WHERE nb.constraint_name = V.index_name AND nb.owner = V.INDEX_OWNER AND NB.CON_ID = V.CON_ID AND nb.constraint_type = 'P') is_primary_key, PARTITIONED, IND_COLS_COUNT, (SELECT round(SUM(bytes) / 1024 / 1024, 2) FROM CDB_segments nd WHERE segment_name = index_name AND nd.owner = INDEX_OWNER AND ND.CON_ID = V.CON_ID) INDEX_SIZE_M, TABLESPACE_NAME, STATUS, -- VISIBILITY, LAST_ANALYZED, DEGREE, NUM_ROWS, SELECTIVITY, STALE_STATS, , Index Height, , , KEYAverage Leaf Block Count, KEY, Clustering Factor, COMPRESSION, LOGGING, (SELECT d.CREATED FROM CDB_OBJECTS d WHERE d.OBJECT_NAME = INDEX_NAME AND d.OBJECT_TYPE = 'INDEX' AND d.OWNER = INDEX_OWNER AND D.CON_ID = V.CON_ID) INDEX_CREATE FROM (SELECT di.con_id, di.owner index_owner, di.table_owner, di.table_name, di.index_name, di.index_type, di.uniqueness, di.partitioned, (SELECT COUNT(1) FROM CDB_ind_columns dic WHERE dic.index_name = di.index_name AND dic.table_name = di.table_name AND dic.INDEX_OWNER = di.owner and dic.CON_ID = di.CON_ID) IND_COLS_COUNT, di.tablespace_name, di.status, --di.visibility, di.last_analyzed, di.degree, di.num_rows, DECODE(di.num_rows, 0, '', round(di.distinct_keys / di.num_rows, 2)) selectivity, DIS.STALE_STATS, di.BLEVEL , di.blevel + 1 Index Height, di.LEAF_BLOCKS , di.DISTINCT_KEYS , di.AVG_LEAF_BLOCKS_PER_KEY KEYAverage Leaf Block Count, di.AVG_DATA_BLOCKS_PER_KEY KEY, di.clustering_factor Clustering Factor, di.compression, di.logging FROM CDB_indexes di LEFT OUTER JOIN CDB_ind_statistics dis ON (di.owner = dis.owner AND di.index_name = dis.INDEX_NAME AND di.table_name = dis.TABLE_NAME AND di.table_owner = dis.TABLE_OWNER AND di.CON_ID = dis.CON_ID and dis.OBJECT_TYPE = 'INDEX') WHERE di.index_type != 'LOB' AND DI.owner not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND exists (SELECT 1 FROM CDB_segments nd where segment_name = di.index_name AND nd.owner = owner and nd.con_id = di.con_id)) V WHERE IND_COLS_COUNT >= 4; prompt
host echo " 3. . . ." prompt prompt 3
prompt NOTE: Index Height3 CLEAR COLUMNS COMPUTES SET DEFINE OFF --COLUMN IND_COLS_COUNT11 FORMAT a75 HEADING '' ENTMAP OFF COLUMN PARTITIONED FORMAT a11 HEADING 'PARTITIONED' ENTMAP OFF COLUMN IS_PRIMARY_KEY FORMAT a15 HEADING 'IS_PRIMARY_KEY' ENTMAP OFF COLUMN LAST_ANALYZED FORMAT a140 HEADING ' LAST_ANALYZED ' ENTMAP OFF COLUMN INDEX_CREATE FORMAT a140 HEADING ' INDEX_CREATE ' ENTMAP OFF SET DEFINE ON SELECT TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME, INDEX_TYPE, UNIQUENESS, (SELECT DECODE(nb.constraint_type, 'P', 'YES') FROM cdb_constraints nb WHERE nb.constraint_name = V.index_name AND nb.owner = V.INDEX_OWNER AND NB.CON_ID = V.CON_ID AND nb.constraint_type = 'P') is_primary_key, PARTITIONED, IND_COLS_COUNT, (SELECT round(SUM(bytes) / 1024 / 1024, 2) FROM CDB_segments nd WHERE segment_name = index_name AND nd.owner = INDEX_OWNER AND ND.CON_ID = V.CON_ID) INDEX_SIZE_M, TABLESPACE_NAME, STATUS, -- VISIBILITY, LAST_ANALYZED, DEGREE, NUM_ROWS, SELECTIVITY, STALE_STATS, , Index Height, , , KEYAverage Leaf Block Count, KEY, Clustering Factor, COMPRESSION, LOGGING, (SELECT d.CREATED FROM CDB_OBJECTS d WHERE d.OBJECT_NAME = INDEX_NAME AND d.OBJECT_TYPE = 'INDEX' AND d.OWNER = INDEX_OWNER AND D.CON_ID = V.CON_ID) INDEX_CREATE FROM (SELECT di.con_id, di.owner index_owner, di.table_owner, di.table_name, di.index_name, di.index_type, di.uniqueness, di.partitioned, (SELECT COUNT(1) FROM CDB_ind_columns dic WHERE dic.index_name = di.index_name AND dic.table_name = di.table_name AND dic.INDEX_OWNER = di.owner and dic.CON_ID = di.CON_ID) IND_COLS_COUNT, di.tablespace_name, di.status, --di.visibility, di.last_analyzed, di.degree, di.num_rows, DECODE(di.num_rows, 0, '', round(di.distinct_keys / di.num_rows, 2)) selectivity, DIS.STALE_STATS, di.BLEVEL , di.blevel + 1 Index Height, di.LEAF_BLOCKS , di.DISTINCT_KEYS , di.AVG_LEAF_BLOCKS_PER_KEY KEYAverage Leaf Block Count, di.AVG_DATA_BLOCKS_PER_KEY KEY, di.clustering_factor Clustering Factor, di.compression, di.logging FROM CDB_indexes di LEFT OUTER JOIN CDB_ind_statistics dis ON (di.owner = dis.owner AND di.index_name = dis.INDEX_NAME AND di.table_name = dis.TABLE_NAME AND di.table_owner = dis.TABLE_OWNER AND di.CON_ID = dis.CON_ID and dis.OBJECT_TYPE = 'INDEX') WHERE di.index_type != 'LOB' AND DI.owner not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND exists (SELECT 1 FROM CDB_segments nd where segment_name = di.index_name AND nd.owner = owner and nd.con_id = di.con_id)) V WHERE Index Height >= 4; prompt
host echo " . . . ." prompt prompt [Next Item]
prompt NOTE: CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN STALE_STATS FORMAT a11 HEADING 'STALE_STATS' ENTMAP OFF COLUMN PARTITIONED FORMAT a11 HEADING 'PARTITIONED' ENTMAP OFF COLUMN IS_PRIMARY_KEY FORMAT a15 HEADING 'IS_PRIMARY_KEY' ENTMAP OFF COLUMN LAST_ANALYZED FORMAT a140 HEADING ' LAST_ANALYZED ' ENTMAP OFF COLUMN INDEX_CREATE FORMAT a140 HEADING ' INDEX_CREATE ' ENTMAP OFF SET DEFINE ON SELECT TABLE_OWNER, TABLE_NAME, INDEX_OWNER, INDEX_NAME, INDEX_TYPE, UNIQUENESS, (SELECT DECODE(nb.constraint_type, 'P', 'YES') FROM cdb_constraints nb WHERE nb.constraint_name = V.index_name AND nb.owner = V.INDEX_OWNER AND NB.CON_ID = V.CON_ID AND nb.constraint_type = 'P') is_primary_key, PARTITIONED, IND_COLS_COUNT, (SELECT round(SUM(bytes) / 1024 / 1024, 2) FROM CDB_segments nd WHERE segment_name = index_name AND nd.owner = INDEX_OWNER AND ND.CON_ID = V.CON_ID) INDEX_SIZE_M, TABLESPACE_NAME, STATUS, -- VISIBILITY, LAST_ANALYZED, DEGREE, NUM_ROWS, SELECTIVITY, STALE_STATS, , Index Height, , , KEYAverage Leaf Block Count, KEY, Clustering Factor, COMPRESSION, LOGGING, (SELECT d.CREATED FROM CDB_OBJECTS d WHERE d.OBJECT_NAME = INDEX_NAME AND d.OBJECT_TYPE = 'INDEX' AND d.OWNER = INDEX_OWNER AND D.CON_ID = V.CON_ID) INDEX_CREATE FROM (SELECT di.con_id, di.owner index_owner, di.table_owner, di.table_name, di.index_name, di.index_type, di.uniqueness, di.partitioned, (SELECT COUNT(1) FROM CDB_ind_columns dic WHERE dic.index_name = di.index_name AND dic.table_name = di.table_name AND dic.INDEX_OWNER = di.owner and dic.CON_ID = di.CON_ID) IND_COLS_COUNT, di.tablespace_name, di.status, --di.visibility, di.last_analyzed, di.degree, di.num_rows, DECODE(di.num_rows, 0, '', round(di.distinct_keys / di.num_rows, 2)) selectivity, DIS.STALE_STATS, di.BLEVEL , di.blevel + 1 Index Height, di.LEAF_BLOCKS , di.DISTINCT_KEYS , di.AVG_LEAF_BLOCKS_PER_KEY KEYAverage Leaf Block Count, di.AVG_DATA_BLOCKS_PER_KEY KEY, di.clustering_factor Clustering Factor, di.compression, di.logging FROM CDB_indexes di LEFT OUTER JOIN CDB_ind_statistics dis ON (di.owner = dis.owner AND di.index_name = dis.INDEX_NAME AND di.table_name = dis.TABLE_NAME AND di.table_owner = dis.TABLE_OWNER AND di.CON_ID = dis.CON_ID and dis.OBJECT_TYPE = 'INDEX') WHERE di.index_type != 'LOB' AND DI.owner not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND exists (SELECT 1 FROM CDB_segments nd where segment_name = di.index_name AND nd.owner = owner and nd.con_id = di.con_id)) V WHERE STALE_STATS ='YES'; prompt
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ host echo " Degree of Parallelism. . ." prompt prompt Degree of Parallelism
prompt
prompt prompt Degree of Parallelism
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT t.CON_ID, t.owner, t.table_name, degree FROM cdb_tables t where (trim(t.degree) >'1' or trim(t.degree)='DEFAULT') AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') order by t.CON_ID, t.owner, t.table_name; prompt
prompt prompt Degree of Parallelism
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT t.con_id, t.owner, t.table_name, index_name, degree, status FROM cdb_indexes t where (trim(t.degree) >'1' or trim(t.degree)='DEFAULT') AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') order by t.con_id ,t.owner, t.table_name ; prompt
host echo " . . ." prompt prompt
prompt
host echo " . . . ." prompt prompt
SET DEFINE OFF SET DEFINE ON prompt NOTE: :&_ALERTLOG_PATH prompt prompt ● View200[Next Item]
--SELECT '' message_text FROM T_ALERT_CHECKHELTH_CLOB_LHR; --SELECT '' message_text FROM T_ALERT_CHECKHELTH_CLOB_LHR; SET DEFINE OFF COLUMN alert_date FORMAT a180 HEADING ' alert_date ' ENTMAP OFF COLUMN message_text FORMAT a300 HEADING ' message_text ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT a.CON_ID, --a.CONTAINER_NAME, to_char(originating_timestamp, 'YYYY-MM-DD HH24:MI:SS') alert_date, message_text, --a.ADR_HOME, a.HOST_ID, a.HOST_ADDRESS, a.PROCESS_ID, a.RECORD_ID, a.FILENAME, DENSE_RANK() OVER(PARTITION BY a.CON_ID ORDER BY a.RECORD_ID DESC) RN from v$diag_alert_ext a where trim(a.COMPONENT_ID) = 'rdbms' AND A.FILENAME = (SELECT D.VALUE || (SELECT CASE WHEN D.PLATFORM_NAME LIKE '%Microsoft%' THEN CHR(92) ELSE CHR(47) END PLATFORM FROM V$DATABASE D) || 'log.xml' FROM V$DIAG_INFO D WHERE D.NAME = 'Diag Alert') and originating_timestamp >= sysdate - 7 and trim(a.MESSAGE_TEXT) IS NOT NULL) where rn <= 200 order by record_id; prompt
-------View100 prompt prompt prompt ● View100(),
SET DEFINE OFF COLUMN alert_date FORMAT a180 HEADING ' alert_date ' ENTMAP OFF COLUMN message_text FORMAT a300 HEADING ' message_text ' ENTMAP OFF SET DEFINE ON SELECT b.* FROM (SELECT a.con_id, to_char(originating_timestamp, 'YYYY-MM-DD HH24:MI:SS') alert_date, message_text, --a.ADR_HOME, a.HOST_ID, a.HOST_ADDRESS, a.PROCESS_ID, a.RECORD_ID, a.FILENAME, DENSE_RANK() over(partition by con_id ORDER BY RECORD_ID desc) rank_order from v$diag_alert_ext a where trim(a.COMPONENT_ID) = 'rdbms' AND A.FILENAME = (SELECT D.VALUE || (SELECT CASE WHEN D.PLATFORM_NAME LIKE '%Microsoft%' THEN CHR(92) ELSE CHR(47) END PLATFORM FROM V$DATABASE D) || 'log.xml' FROM V$DIAG_INFO D WHERE D.NAME = 'Diag Alert') and originating_timestamp >= SYSDATE - 15 and message_text NOT LIKE '%advanced to log sequence%' AND message_text NOT LIKE ' Current log#%' AND message_text NOT LIKE 'Archived Log entry%' AND message_text NOT LIKE 'LNS: Standby redo logfile selected for thread %') b WHERE b.rank_order <= 100 order by record_id; -------View10ora prompt prompt ● View10oraAlert log entries in reverse chronological order
SET DEFINE OFF COLUMN alert_date FORMAT a180 HEADING ' alert_date ' ENTMAP OFF COLUMN message_text FORMAT a300 HEADING ' message_text ' ENTMAP OFF SET DEFINE ON SELECT b.* FROM (SELECT a.con_id, to_char(originating_timestamp, 'YYYY-MM-DD HH24:MI:SS') alert_date, message_text, --a.ADR_HOME, a.HOST_ID, a.HOST_ADDRESS, a.PROCESS_ID, a.RECORD_ID, a.FILENAME, DENSE_RANK() over(partition by con_id ORDER BY RECORD_ID desc) rank_order from v$diag_alert_ext a where trim(a.COMPONENT_ID) = 'rdbms' AND A.FILENAME = (SELECT D.VALUE || (SELECT CASE WHEN D.PLATFORM_NAME LIKE '%Microsoft%' THEN CHR(92) ELSE CHR(47) END PLATFORM FROM V$DATABASE D) || 'log.xml' FROM V$DIAG_INFO D WHERE D.NAME = 'Diag Alert') and originating_timestamp >= SYSDATE - 15 and message_text LIKE 'ORA-%') b WHERE b.rank_order <= 10 order by record_id; -------,1W0.5M prompt prompt ●
prompt NOTE: ,, SELECT d.total_rows_number total_rows_number, case WHEN total_rows_number > 3000000 then round(total_rows_number / 10000 * 0.9, 2) WHEN total_rows_number > 1000000 then round(total_rows_number / 10000 * 0.75, 2) WHEN total_rows_number > 500000 then round(total_rows_number / 10000 * 0.7, 2) WHEN total_rows_number > 10000 then round(total_rows_number / 10000 * 0.65, 2) else round(total_rows_number / 10000 * 0.5, 2) end file_size_M FROM (SELECT count(*) total_rows_number from v$diag_alert_ext a where trim(a.COMPONENT_ID) = 'rdbms' AND A.FILENAME = (SELECT D.VALUE || (SELECT CASE WHEN D.PLATFORM_NAME LIKE '%Microsoft%' THEN CHR(92) ELSE CHR(47) END PLATFORM FROM V$DATABASE D) || 'log.xml' FROM V$DIAG_INFO D WHERE D.NAME = 'Diag Alert')) d; prompt
-- +----------------------------------------------------------------------------+ -- | - DIRECTORIES - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt ● Database Directory Overview
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN directory_name FORMAT a75 HEADING 'Directory Name' ENTMAP OFF COLUMN directory_path HEADING 'Directory Path' ENTMAP OFF -- BREAK ON report ON owner SELECT d.CON_ID,d.ORIGIN_CON_ID,d.OWNER,d.DIRECTORY_NAME,d.DIRECTORY_PATH FROM CDB_DIRECTORIES d ORDER BY d.CON_ID,OWNER, DIRECTORY_NAME; -- +----------------------------------------------------------------------------+ -- | - DIRECTORY PRIVILEGES - | -- +----------------------------------------------------------------------------+ prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN table_name FORMAT a75 HEADING 'Directory Name' ENTMAP OFF COLUMN grantee FORMAT a75 HEADING 'Grantee' ENTMAP OFF COLUMN privilege FORMAT a75 HEADING 'Privilege' ENTMAP OFF COLUMN grantable FORMAT a75 HEADING 'Grantable?' ENTMAP OFF -- BREAK ON report ON table_name ON grantee SELECT d.CON_ID, d.GRANTEE, d.OWNER, d.TABLE_NAME, d.GRANTOR, d.PRIVILEGE, DECODE(grantable, 'YES', '
-- +----------------------------------------------------------------------------+ -- | - RECYCLE BIN - | -- +----------------------------------------------------------------------------+ prompt prompt
-- BREAK ON report ON owner prompt ● Size of Recycle Bin Objects
SELECT a.CON_ID, nvl(a.owner, '') owner, round(SUM(a.space * (SELECT value FROM v$parameter WHERE name = 'db_block_size')) / 1024 / 1024, 3) recyb_size, count(1) recyb_cnt FROM cdb_recyclebin a GROUP BY a.CON_ID, ROLLUP(a.owner); prompt
prompt ● 10Objects
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a85 HEADING 'Owner' ENTMAP OFF COLUMN original_name HEADING 'original_name' ENTMAP OFF COLUMN type HEADING 'Object|Type' ENTMAP OFF COLUMN object_name HEADING 'object_name' ENTMAP OFF COLUMN ts_name HEADING 'Tablespace' ENTMAP OFF COLUMN operation HEADING 'Operation' ENTMAP OFF COLUMN createtime HEADING 'createtime' ENTMAP OFF COLUMN droptime HEADING 'droptime' ENTMAP OFF COLUMN can_undrop HEADING 'Can|Undrop?' ENTMAP OFF COLUMN can_purge HEADING 'Can|Purge?' ENTMAP OFF COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Bytes' ENTMAP OFF SELECT * FROM (SELECT r.CON_ID, '
') || '
') || '
', 'YES', '
', 'YES', '
-- +----------------------------------------------------------------------------+ -- | - DB LINKS - | -- +----------------------------------------------------------------------------+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN db_link FORMAT a75 HEADING 'DB Link Name' ENTMAP OFF COLUMN username HEADING 'Username' ENTMAP OFF COLUMN host HEADING 'Host' ENTMAP OFF COLUMN CREATED FORMAT a140 HEADING ' CREATED ' ENTMAP OFF -- BREAK ON owner SELECT a.CON_ID, '' || owner || '' owner, db_link, username, host, '
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT a.CON_ID, a.OWNER, a.TABLE_NAME, a.TYPE_OWNER, a.TYPE_NAME, a.DEFAULT_DIRECTORY_OWNER, a.DEFAULT_DIRECTORY_NAME, a.REJECT_LIMIT, a.ACCESS_TYPE, a.ACCESS_PARAMETERS, a.PROPERTY FROM cdb_external_tables a order by con_id, owner; prompt
-------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------- prompt prompt
prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, OWNER, count(1) cnt FROM cdb_triggers d GROUP BY d.CON_ID, owner ORDER BY d.CON_ID, cnt desc; prompt ● ,,10
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) SELECT * FROM (SELECT d.CON_ID, OWNER, TRIGGER_NAME, d.trigger_type, d.triggering_event, d.table_owner, d.base_object_type, TABLE_NAME, STATUS, d.when_clause, DENSE_RANK() over(partition by d.owner, d.trigger_type ORDER BY d.trigger_name) rank_order FROM cdb_triggers d WHERE d.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ) wd WHERE rank_order <= 10 ORDER BY wd.con_id, wd.owner, wd.status; prompt
prompt ● database
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, OWNER, TRIGGER_NAME, d.trigger_type, d.triggering_event, d.table_owner, d.base_object_type, TABLE_NAME, STATUS, d.when_clause FROM cdb_triggers d WHERE d.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') and d.base_object_type like 'DATABASE%' ORDER BY d.CON_ID,d.owner,d.status ; prompt
prompt ● DISABLED
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.CON_ID, OWNER, TRIGGER_NAME, TABLE_NAME, STATUS, (SELECT nb.status FROM cdb_objects nb WHERE nb.OWNER = d.owner AND nb.OBJECT_NAME = d.trigger_name and nb.CON_ID=d.CON_ID) STATUS1 FROM cdb_triggers d WHERE owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND d.status <> 'ENABLED' ORDER BY d.CON_ID, d.owner, d.status; prompt
prompt prompt cacheless than20
prompt ● cacheless than20,,1000,20Too Small
CLEAR COLUMNS COMPUTES SET DEFINE OFF prompt ● SELECT t.CON_ID, sequence_owner, count(1) cnt FROM cdb_sequences t WHERE cache_size < 20 AND sequence_owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY t.CON_ID, t.sequence_owner ORDER BY cnt desc; prompt ● COLUMN order_flag FORMAT a10 HEADING 'order_flag' ENTMAP OFF SELECT t.CON_ID, sequence_owner, sequence_name, cache_size, t.order_flag, 'alter sequence ' || t.sequence_owner || '.' || t.sequence_name || ' cache 1000;' alter_sequence FROM cdb_sequences t WHERE cache_size < 20 AND sequence_owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') order by t.CON_ID, t.SEQUENCE_OWNER; prompt prompt NOTE: AUDSES$, SELECT * FROM cdb_sequences d WHERE d.sequence_name ='AUDSES$' order by con_id; prompt prompt ● ,cache
prompt ● SELECT WB.*, 'ALTER SEQUENCE ' || WB.USERNAME || '.' || WB.SEQUENCE_NAME || ' CACHE 1000;' alter_sequence FROM (SELECT DISTINCT d.CON_ID, D.EVENT, D.P2, A.USERNAME, (SELECT DO.OBJECT_NAME FROM cdb_OBJECTS DO WHERE DO.OBJECT_ID = D.P2 and do.CON_ID=d.CON_ID) SEQUENCE_NAME, (SELECT DS.CACHE_SIZE FROM cdb_OBJECTS DO, cdb_SEQUENCES DS WHERE DO.OBJECT_ID = D.P2 AND DS.SEQUENCE_NAME = DO.OBJECT_NAME AND DS.SEQUENCE_OWNER = DO.OWNER and do.CON_ID=ds.CON_ID and do.CON_ID=d.CON_ID) SEQUENCE_CACHE FROM cdb_HIST_ACTIVE_SESS_HISTORY D, cdb_USERS A WHERE D.USER_ID = A.USER_ID and d.CON_ID=a.CON_ID AND USERNAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND D.EVENT LIKE 'enq: SQ%') WB order by CON_ID; prompt ● Details(200) SELECT * FROM (SELECT d.CON_ID, TO_CHAR(D.SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') SAMPLE_TIME, D.SAMPLE_ID, D.SESSION_ID, D.SESSION_SERIAL#, D.SESSION_TYPE, D.BLOCKING_SESSION, D.BLOCKING_SESSION_SERIAL#, D.EVENT, D.P2, A.USERNAME, (SELECT DO.OBJECT_NAME FROM cdb_OBJECTS DO WHERE DO.OBJECT_ID = D.P2 and do.CON_ID=d.CON_ID) SEQUENCE_NAME, (SELECT DS.CACHE_SIZE FROM cdb_OBJECTS DO, cdb_SEQUENCES DS WHERE DO.OBJECT_ID = D.P2 AND DS.SEQUENCE_NAME = DO.OBJECT_NAME AND DS.SEQUENCE_OWNER = DO.OWNER and do.CON_ID=ds.CON_ID and d.CON_ID=d.CON_ID) SEQUENCE_CACHE, DENSE_RANK() OVER(PARTITION BY D.P2 ORDER BY D.SAMPLE_TIME DESC) AS DRANK FROM cdb_HIST_ACTIVE_SESS_HISTORY D, cdb_USERS A WHERE D.USER_ID = A.USER_ID and d.CON_ID=a.CON_ID AND USERNAME NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND D.EVENT LIKE 'enq: SQ%') WHERE DRANK <= 2 AND ROWNUM <= 200 order by con_id, SAMPLE_TIME desc; prompt
-- +----------------------------------------------------------------------------+ -- | - MATERIALIZED VIEWS - | -- +----------------------------------------------------------------------------+ prompt prompt
prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT d.NAME, d.VALUE, d.ISDEFAULT, d.ISSES_MODIFIABLE, d.ISSYS_MODIFIABLE, d.DESCRIPTION FROM v$parameter d WHERE upper(d.NAME) in ('JOB_QUEUE_PROCESSES', 'QUERY_REWRITE_ENABLED', 'QUERY_REWRITE_INTEGRITY', 'OPTIMIZER_MODE') ; prompt ●
prompt NOTE: 500 CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT a.con_id, a.OWNER, a.MVIEW_NAME, --a.QUERY, a.REWRITE_ENABLED, a.REFRESH_MODE, a.REFRESH_METHOD, a.BUILD_MODE, c.comments, e.log_table, f.last_refresh FROM cdb_mviews a LEFT OUTER JOIN CDB_refresh b on (a.OWNER = b.ROWNER AND a.MVIEW_NAME = b.RNAME and a.CON_ID = b.CON_ID) LEFT OUTER JOIN CDB_mview_comments c on (a.OWNER = c.OWNER AND a.MVIEW_NAME = c.MVIEW_NAME and a.CON_ID = c.CON_ID) LEFT OUTER JOIN CDB_mview_detail_relations d on (a.OWNER = d.OWNER AND a.MVIEW_NAME = d.MVIEW_NAME and d.MVIEW_NAME = b.RNAME and a.CON_ID = d.CON_ID) LEFT OUTER JOIN CDB_mview_logs e on (a.OWNER = d.OWNER AND d.detailobj_name = e.master and a.CON_ID = e.CON_ID) LEFT OUTER JOIN CDB_mview_refresh_times f on (a.OWNER = f.OWNER AND e.master = f.master and a.CON_ID = f.CON_ID) WHERE a.OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') order by a.con_id, a.owner; prompt
prompt prompt Materialized Views
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN mview_name FORMAT a75 HEADING 'MView|Name' ENTMAP OFF COLUMN master_link FORMAT a75 HEADING 'Master|Link' ENTMAP OFF COLUMN updatable FORMAT a75 HEADING 'Updatable?' ENTMAP OFF COLUMN update_log FORMAT a75 HEADING 'Update|Log' ENTMAP OFF COLUMN rewrite_enabled FORMAT a75 HEADING 'Rewrite|Enabled?' ENTMAP OFF COLUMN refresh_mode FORMAT a75 HEADING 'Refresh|Mode' ENTMAP OFF COLUMN refresh_method FORMAT a75 HEADING 'Refresh|Method' ENTMAP OFF COLUMN build_mode FORMAT a75 HEADING 'Build|Mode' ENTMAP OFF COLUMN fast_refreshable FORMAT a75 HEADING 'Fast|Refreshable' ENTMAP OFF COLUMN last_refresh_type FORMAT a75 HEADING 'Last Refresh|Type' ENTMAP OFF COLUMN last_refresh_date FORMAT a75 HEADING 'Last Refresh|Date' ENTMAP OFF COLUMN staleness FORMAT a75 HEADING 'Staleness' ENTMAP OFF COLUMN compile_state FORMAT a75 HEADING 'Compile State' ENTMAP OFF -- BREAK ON owner SELECT m.con_id, '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - MATERIALIZED VIEW LOGS - | -- +----------------------------------------------------------------------------+ prompt prompt Materialized View Logs
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN log_owner FORMAT a75 HEADING 'Log Owner' ENTMAP OFF COLUMN log_table FORMAT a75 HEADING 'Log Table' ENTMAP OFF COLUMN master FORMAT a75 HEADING 'Master' ENTMAP OFF COLUMN log_trigger FORMAT a75 HEADING 'Log Trigger' ENTMAP OFF COLUMN rowids FORMAT a75 HEADING 'Rowids?' ENTMAP OFF COLUMN primary_key FORMAT a75 HEADING 'Primary Key?' ENTMAP OFF COLUMN object_id FORMAT a75 HEADING 'Object ID?' ENTMAP OFF COLUMN filter_columns FORMAT a75 HEADING 'Filter Columns?' ENTMAP OFF COLUMN sequence FORMAT a75 HEADING 'Sequence?' ENTMAP OFF COLUMN include_new_values FORMAT a75 HEADING 'Include New Values?' ENTMAP OFF -- BREAK ON log_owner SELECT ml.con_id, '
') || '
') || '
') || '
') || '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - MATERIALIZED VIEW REFRESH GROUPS - | -- +----------------------------------------------------------------------------+ prompt prompt Materialized View Refresh Groups
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN name FORMAT a75 HEADING 'Name' ENTMAP OFF COLUMN broken FORMAT a75 HEADING 'Broken?' ENTMAP OFF COLUMN next_date FORMAT a140 HEADING ' next_date ' ENTMAP OFF COLUMN interval FORMAT a75 HEADING 'Interval' ENTMAP OFF SET DEFINE ON -- BREAK ON report ON owner SELECT d.con_id, '
') || '
-- +----------------------------------------------------------------------------+ -- | - TYPES - | -- +----------------------------------------------------------------------------+ prompt prompt Types
prompt NOTE: Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN type_name FORMAT a75 HEADING 'Type Name' ENTMAP OFF COLUMN typecode FORMAT a75 HEADING 'Type Code' ENTMAP OFF COLUMN attributes FORMAT a75 HEADING 'Num. Attributes' ENTMAP OFF COLUMN methods FORMAT a75 HEADING 'Num. Methods' ENTMAP OFF COLUMN predefined FORMAT a75 HEADING 'Predefined?' ENTMAP OFF COLUMN incomplete FORMAT a75 HEADING 'Incomplete?' ENTMAP OFF COLUMN final FORMAT a75 HEADING 'Final?' ENTMAP OFF COLUMN instantiable FORMAT a75 HEADING 'Instantiable?' ENTMAP OFF COLUMN supertype_owner FORMAT a75 HEADING 'Super Owner' ENTMAP OFF COLUMN supertype_name FORMAT a75 HEADING 'Super Name' ENTMAP OFF COLUMN local_attributes FORMAT a75 HEADING 'Local Attributes' ENTMAP OFF COLUMN local_methods FORMAT a75 HEADING 'Local Methods' ENTMAP OFF -- BREAK ON report ON owner SELECT t.CON_ID, '
') || '
') || '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - TYPE METHODS - | -- +----------------------------------------------------------------------------+ prompt prompt ● Type Methods
prompt Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP OFF COLUMN type_name FORMAT a75 HEADING 'Type Name' ENTMAP OFF COLUMN typecode FORMAT a75 HEADING 'Type Code' ENTMAP OFF COLUMN method_name FORMAT a75 HEADING 'Method Name' ENTMAP OFF COLUMN method_type FORMAT a75 HEADING 'Method Type' ENTMAP OFF COLUMN num_parameters FORMAT a75 HEADING 'Num. Parameters' ENTMAP OFF COLUMN results FORMAT a75 HEADING 'Results' ENTMAP OFF COLUMN final FORMAT a75 HEADING 'Final?' ENTMAP OFF COLUMN instantiable FORMAT a75 HEADING 'Instantiable?' ENTMAP OFF COLUMN overriding FORMAT a75 HEADING 'Overriding?' ENTMAP OFF COLUMN inherited FORMAT a75 HEADING 'Inherited?' ENTMAP OFF -- BREAK ON report ON owner ON type_name ON typecode SELECT t.con_id,'
-- +============================================================================+ -- | | -- | <<<<< DATA PUMP >>>>> | -- | | -- +============================================================================+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner_name FORMAT a75 HEADING 'Owner Name' ENTMAP OFF COLUMN job_name FORMAT a75 HEADING 'Job Name' ENTMAP OFF COLUMN operation FORMAT a75 HEADING 'Operation' ENTMAP OFF COLUMN job_mode FORMAT a75 HEADING 'Job Mode' ENTMAP OFF COLUMN state FORMAT a75 HEADING 'State' ENTMAP OFF COLUMN degree FORMAT 999,999,999 HEADING 'Degree' ENTMAP OFF COLUMN attached_sessions FORMAT 999,999,999 HEADING 'Attached Sessions' ENTMAP OFF col owner_name for a10 col job_name for a25 col operation for a10 col job_mode for a10 col state for a15 col job_mode for a10 col state for a15 col osuser for a10 col "degree|attached|datapump" for a25 col session_info for a20 SELECT dj.CON_ID, s.inst_id, dj.owner_name, dj.job_name, dj.operation, dj.job_mode, dj.state, dj.degree || ',' || dj.attached_sessions || ',' || dj.datapump_sessions "degree|attached|datapump", ds.session_type, s.osuser, (SELECT s.SID || ',' || s.SERIAL# || ',' || p.SPID FROM gv$process p WHERE s.paddr = p.addr AND s.inst_id = p.inst_id and p.con_id=dj.con_id) session_info FROM CDB_DATAPUMP_JOBS dj --gv$datapump_job full outer join CDB_datapump_sessions ds --gv$datapump_session on (dj.job_name = ds.job_name AND dj.owner_name = ds.owner_name AND DJ.CON_ID=DS.CON_ID) LEFT OUTER JOIN gv$session s on (s.saddr = ds.saddr AND DJ.CON_ID=S.CON_ID) ORDER BY dj.owner_name, dj.job_name; prompt
-- +----------------------------------------------------------------------------+ -- | - DATA PUMP SESSIONS - | -- +----------------------------------------------------------------------------+ prompt prompt Data Pump Sessions
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a75 HEADING 'Instance_Name' ENTMAP OFF COLUMN owner_name FORMAT a75 HEADING 'Owner Name' ENTMAP OFF COLUMN job_name FORMAT a75 HEADING 'Job Name' ENTMAP OFF COLUMN session_type FORMAT a75 HEADING 'Session Type' ENTMAP OFF COLUMN sid HEADING 'SID' ENTMAP OFF COLUMN serial_no HEADING 'Serial#' ENTMAP OFF COLUMN oracle_username FORMAT a75 HEADING 'Oracle Username' ENTMAP OFF COLUMN os_username FORMAT a75 HEADING 'O/S Username' ENTMAP OFF COLUMN os_pid HEADING 'O/S PID' ENTMAP OFF -- BREAK ON report ON instance_name_print ON owner_name ON job_name SELECT '
-- +----------------------------------------------------------------------------+ -- | - DATA PUMP JOB PROGRESS - | -- +----------------------------------------------------------------------------+ prompt prompt Data Pump Job Progress
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a75 HEADING 'Instance_Name' ENTMAP OFF COLUMN owner_name FORMAT a75 HEADING 'Owner Name' ENTMAP OFF COLUMN job_name FORMAT a75 HEADING 'Job Name' ENTMAP OFF COLUMN session_type FORMAT a75 HEADING 'Session Type' ENTMAP OFF COLUMN START_TIME FORMAT a140 HEADING ' START_TIME ' ENTMAP OFF COLUMN time_remaining FORMAT 9,999,999,999,999 HEADING 'Time Remaining (min.)' ENTMAP OFF COLUMN sofar FORMAT 9,999,999,999,999 HEADING 'Bytes Completed So Far' ENTMAP OFF COLUMN totalwork FORMAT 9,999,999,999,999 HEADING 'Total Bytes for Job' ENTMAP OFF COLUMN pct_completed HEADING '% Completed' ENTMAP OFF SET DEFINE ON -- BREAK ON report ON instance_name_print ON owner_name ON job_name SELECT '
-- +----------------------------------------------------------------------------+ -- | - - | -- +----------------------------------------------------------------------------+ -- +============================================================================+ -- | | -- | <<<<< AUTOMATIC WORKLOAD REPOSITORY - (AWR) >>>>> | -- | | -- +============================================================================+ -- +====================================================================================================================+ -- | -- | <<<<< >>>>> | -- | | -- +====================================================================================================================+ host echo start.... . prompt prompt
host echo " AWR. . ." prompt prompt AWR
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_number FORMAT a100 HEADING '|' ENTMAP OFF COLUMN snap_time FORMAT a22 HEADING '' ENTMAP OFF COLUMN mem_read FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN disk_read FORMAT 999,999,999,999,999 HEADING '(MB)' ENTMAP OFF COLUMN disk_write FORMAT 999,999,999,999,999 HEADING '(KB)' ENTMAP OFF COLUMN log_account FORMAT 999,999,999,999,999 HEADING '(KB)' ENTMAP OFF COLUMN hard_parse FORMAT 999,999,999,999,999 HEADING '()' ENTMAP OFF COLUMN total_parse FORMAT 999,999,999,999,999 HEADING '()' ENTMAP OFF COLUMN trans FORMAT 999,999,999,999,999 HEADING '' ENTMAP OFF COLUMN cpu_time FORMAT 999,999,999,999,999 HEADING 'CPU()' ENTMAP OFF -- BREAK ON report ON instance_number snap_time, instance_number, stat_name AS name, value FROM (SELECT cast(c.end_interval_time AS date) snap_time, a.instance_number, b.stat_name, a.value FROM sys.wrh$_sysstat a, sys.wrh$_stat_name b, sys.WRM$_SNAPSHOT C WHERE a.dbid = b.dbid AND a.stat_id = b.stat_id AND a.dbid = c.dbid AND a.instance_number = c.instance_number AND b.stat_name in ('session logical reads', 'physical reads', 'execute count', 'redo size', 'parse count (hard)', 'parse count (total)', 'physical writes', 'user commits', 'user rollbacks', 'CPU used by this session') AND c.end_interval_time>sysdate -7) ) SELECT '
prompt AWR
prompt ● prompt Use the DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS procedure to modify the interval prompt of the snapshot generation AND how long the snapshots are retained in the Workload Repository. The prompt default interval is 60 minutes AND can be set to a value between 10 minutes AND 5,256,000 (1 year). prompt The default retention period is 10,080 minutes (7 days) AND can be set to a value between prompt 1,440 minutes (1 day) AND 52,560,000 minutes (100 years). prompt AWR3: prompt ① STATISTICS_LEVELTYPICAL ALL CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN dbbid FORMAT a75 HEAD 'Database ID' ENTMAP OFF COLUMN dbb_name FORMAT a75 HEAD 'Database Name' ENTMAP OFF COLUMN snap_interval FORMAT a75 HEAD 'Snap Interval' ENTMAP OFF COLUMN retention FORMAT a75 HEAD 'Retention Period' ENTMAP OFF COLUMN topnsql FORMAT a75 HEAD 'Top N SQL' ENTMAP OFF SELECT '
prompt
prompt
prompt
prompt prompt AWRin the viewload profile
prompt NOTE: 7AWRin the viewload profile CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN snap_date FORMAT a100 HEADING ' snap_date ' ENTMAP OFF COLUMN cpu_time FORMAT 999,999,999.99 HEADING 'CPU Time (min)' ENTMAP OFF COLUMN snap_time_range FORMAT a340 HEADING ' SNAP_TIME_RANGE ' ENTMAP OFF COLUMN end_interval_time FORMAT a140 HEADING ' End_Interval_Time ' ENTMAP OFF COLUMN startup_time FORMAT a140 HEADING ' startup_time ' ENTMAP OFF SET DEFINE ON with tmp_s as (SELECT curr_redo - last_redo redosize, curr_logicalreads - last_logicalreads logicalreads, curr_physicalreads - last_physicalreads physicalreads, curr_executes - last_executes executes, curr_parse - last_parse parse, curr_hardparse - last_hardparse hardparse, DECODE((curr_transactions - last_transactions), 0, NULL, (curr_transactions - last_transactions)) transactions, round(((currtime + 0) - (lasttime + 0)) * 3600 * 24, 0) seconds, TO_CHAR(currtime, 'yyyy-mm-dd') snap_date, TO_CHAR(currtime, 'hh24:mi') currtime, TO_CHAR(lasttime, 'YYYY-MM-DD HH24:MI') || '~' || TO_CHAR(currtime, 'YYYY-MM-DD HH24:MI') snap_time_range, TO_CHAR(startup_time, 'yyyy-mm-dd hh24:mi:ss') startup_time, sessions || '~' || currsessions sessions, Cursors1 || '~' || currCursors Cursors2, instance_number FROM (SELECT a.redo last_redo, a.logicalreads last_logicalreads, a.physicalreads last_physicalreads, a.executes last_executes, a.parse last_parse, a.hardparse last_hardparse, a.transactions last_transactions, a.sessions, trunc(a.Cursors / a.sessions, 2) Cursors1, lead(a.redo, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_redo, lead(a.logicalreads, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_logicalreads, lead(a.physicalreads, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_physicalreads, lead(a.executes, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_executes, lead(a.parse, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_parse, lead(a.hardparse, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_hardparse, lead(a.transactions, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) curr_transactions, b.end_interval_time lasttime, lead(b.end_interval_time, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) currtime, lead(a.sessions, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) currsessions, lead(trunc(a.Cursors / a.sessions, 2), 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) currCursors, b.startup_time, b.instance_number dbid, instance_number, SUM(DECODE(stat_name, 'redo size', VALUE, 0)) redo, SUM(DECODE(stat_name, 'session logical reads', VALUE, 0)) logicalreads, SUM(DECODE(stat_name, 'physical reads', VALUE, 0)) physicalreads, SUM(DECODE(stat_name, 'execute count', VALUE, 0)) executes, SUM(DECODE(stat_name, 'parse count (total)', VALUE, 0)) parse, SUM(DECODE(stat_name, 'parse count (hard)', VALUE, 0)) hardparse, SUM(DECODE(stat_name, 'user rollbacks', VALUE, 'user commits', VALUE, 0)) transactions, SUM(DECODE(stat_name, 'logons current', VALUE, 0)) sessions, SUM(DECODE(stat_name, 'opened cursors current', VALUE, 0)) Cursors WHERE stat_name IN ('redo size', 'session logical reads', 'physical reads', 'execute count', 'user rollbacks', 'user commits', 'parse count (hard)', 'parse count (total)', 'logons current', 'opened cursors current') AND a.dbid = b.dbid AND a.instance_number = b.instance_number AND b.end_interval_time > SYSDATE - 7 ORDER BY end_interval_time)), tmp_t as (SELECT lead(a.value, 1, NULL) over(PARTITION BY b.instance_number, b.startup_time ORDER BY b.end_interval_time) - a.value db_time, b.instance_number AND a.dbid = b.dbid AND a.instance_number = b.instance_number AND a.stat_name = 'DB time'), tmp_ash as FROM (SELECT n.instance_number inst_id, n.session_id, n.session_serial# GROUP BY n.instance_number, n.session_id, n.session_serial#) nt SELECT s.snap_date, s.instance_number inst_id, snap_time_range, DECODE(s.redosize, NULL, ' --shutdown or end--', s.currtime) "TIME", startup_time, TO_CHAR(round(s.seconds / 60, 2)) "Elapsed(min)", round(t.db_time / 1000000 / 60, 2) "DB_time(min)", s.sessions, (SELECT counts FROM tmp_ash nnt WHERE s.instance_number = nnt.inst_id (SELECT counts FROM tmp_ash nnt WHERE s.instance_number = nnt.inst_id s.Cursors2 "Cursors/Session", s.redosize redo, round(s.redosize / s.seconds, 2) "redo/s", round(s.redosize / s.transactions, 2) "redo/t", s.logicalreads logical, round(s.logicalreads / s.seconds, 2) "logical/s", round(s.logicalreads / s.transactions, 2) "logical/t", physicalreads physical, round(s.physicalreads / s.seconds, 2) "phy/s", round(s.physicalreads / s.transactions, 2) "phy/t", s.executes execs, round(s.executes / s.seconds, 2) "execs/s", round(s.executes / s.transactions, 2) "execs/t", s.parse, round(s.parse / s.seconds, 2) "parse/s", round(s.parse / s.transactions, 2) "parse/t", s.hardparse, round(s.hardparse / s.seconds, 2) "hardparse/s", round(s.hardparse / s.transactions, 2) "hardparse/t", s.transactions trans, round(s.transactions / s.seconds, 2) "trans/s" FROM tmp_s s, tmp_t t AND t.instance_number = s.instance_number prompt
SET DEFINE ON prompt prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - AWR SNAPSHOT SIZE ESTIMATES - | -- +----------------------------------------------------------------------------+ prompt prompt AWR Snapshot Size Estimates
SET DEFINE ON DECLARE CURSOR get_instances IS SELECT COUNT(DISTINCT instance_number) FROM sys.wrm$_database_instance; CURSOR get_wr_control_info IS SELECT snapint_num, retention_num FROM sys.wrm$_wr_control; CURSOR get_snaps IS SELECT SUM(all_snaps) , SUM(good_snaps) , SUM(today_snaps) , SYSDATE - MIN(begin_interval_time) FROM (SELECT 1 AS all_snaps , (CASE WHEN s.status = 0 THEN 1 ELSE 0 END) AS good_snaps , (CASE WHEN (s.end_interval_time > SYSDATE - 1) THEN 1 ELSE 0 END) AS today_snaps , CAST(s.begin_interval_time AS DATE) AS begin_interval_time FROM sys.wrm$_snapshot s ); CURSOR sysaux_occ_usage IS SELECT occupant_name , schema_name , space_usage_kbytes/1024 space_usage_mb FROM v$sysaux_occupants ORDER BY space_usage_kbytes DESC , occupant_name; mb_format CONSTANT VARCHAR2(30) := '99,999,990.0'; kb_format CONSTANT VARCHAR2(30) := '999,999,990'; pct_format CONSTANT VARCHAR2(30) := '990.0'; snapshot_interval NUMBER; retention_interval NUMBER; all_snaps NUMBER; awr_size NUMBER; snap_size NUMBER; awr_average_size NUMBER; est_today_snaps NUMBER; awr_size_past24 NUMBER; good_snaps NUMBER; today_snaps NUMBER; num_days NUMBER; num_instances NUMBER; BEGIN OPEN get_instances; FETCH get_instances INTO num_instances; CLOSE get_instances; OPEN get_wr_control_info; FETCH get_wr_control_info INTO snapshot_interval, retention_interval; CLOSE get_wr_control_info; OPEN get_snaps; FETCH get_snaps INTO all_snaps, good_snaps, today_snaps, num_days; CLOSE get_snaps; FOR occ_rec IN sysaux_occ_usage LOOP IF (occ_rec.occupant_name = 'SM/AWR') THEN awr_size := occ_rec.space_usage_mb; END IF; END LOOP; snap_size := awr_size/all_snaps; awr_average_size := snap_size*86400/snapshot_interval; today_snaps := today_snaps / num_instances; IF (num_days < 1) THEN est_today_snaps := ROUND(today_snaps / num_days); ELSE est_today_snaps := today_snaps; END IF; awr_size_past24 := snap_size * est_today_snaps; DBMS_OUTPUT.PUT_LINE('
Estimates based on ' || ROUND(snapshot_interval/60) || ' minute snapshot intervals | ||
---|---|---|
AWR size/day | ' || TO_CHAR(awr_average_size, mb_format) || ' MB | (' || TRIM(TO_CHAR(snap_size*1024, kb_format)) || ' K/snap * ' || ROUND(86400/snapshot_interval) || ' snaps/day) |
AWR size/wk | ' || TO_CHAR(awr_average_size * 7, mb_format) || ' MB | (size_per_day * 7) per instance |
AWR size/wk | ' || TO_CHAR(awr_average_size * 7 * num_instances, mb_format) || ' MB | (size_per_day * 7) per database |
Estimates based on ' || ROUND(today_snaps) || ' snaps in past 24 hours | ||
AWR size/day | ' || TO_CHAR(awr_size_past24, mb_format) || ' MB | (' || TRIM(TO_CHAR(snap_size*1024, kb_format)) || ' K/snap AND ' || ROUND(today_snaps) || ' snaps in past ' || ROUND(least(num_days*24,24),1) || ' hours) |
AWR size/wk | ' || TO_CHAR(awr_size_past24 * 7, mb_format) || ' MB | (size_per_day * 7) per instance |
AWR size/wk | ' || TO_CHAR(awr_size_past24 * 7 * num_instances, mb_format) || ' MB | (size_per_day * 7) per database |
-- +----------------------------------------------------------------------------+ -- | - AWR BASELINES - | -- +----------------------------------------------------------------------------+ prompt prompt AWR Baselines
prompt Use the DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE procedure to create a named baseline. prompt A baseline (also known AS a preserved snapshot set) is a pair of AWR snapshots that represents a prompt specific period of database usage. The Oracle database server will exempt the AWR snapshots prompt assigned to a specific baseline FROM the automated purge routine. The main purpose of a baseline prompt is to preserve typical run-time statistics in the AWR repository which can then be compared to prompt current performance or similar periods in the past. CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN dbbid FORMAT a75 HEAD 'Database ID' ENTMAP OFF COLUMN dbb_name FORMAT a75 HEAD 'Database Name' ENTMAP OFF COLUMN baseline_id HEAD 'Baseline ID' ENTMAP OFF COLUMN baseline_name FORMAT a75 HEAD 'Baseline Name' ENTMAP OFF COLUMN start_snap_time FORMAT a75 HEAD 'Beginning Snapshot Time' ENTMAP OFF COLUMN end_snap_time FORMAT a75 HEAD 'Ending Snapshot Time' ENTMAP OFF SET DEFINE ON SELECT '
-- +----------------------------------------------------------------------------+ -- | - ENABLED TRACES - | -- +----------------------------------------------------------------------------+ prompt prompt Enabled Traces
prompt End-to-End Application Tracing FROM View DBA_ENABLED_TRACES. prompt
prompt Application tracing is enabled using the DBMS_MONITOR package AND the following procedures: prompt
prompt Hint: In a shared environment WHERE you have more than one session to trace, it is prompt possible to end up with many trace files WHEN tracing is enabled (i.e. connection pools). prompt Oracle10g introduces the trcsess command-line utility to combine all the relevant prompt trace files based on a session or client identifier or the service name, module name, and prompt action name hierarchy combination. The output trace file FROM the trcsess command can then be prompt sent to tkprof for a formatted output. Type trcsess at the command-line without any arguments to prompt show the parameters AND usage. CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN trace_type FORMAT a75 HEADING 'Trace Type' ENTMAP OFF COLUMN primary_id FORMAT a75 HEADING 'Primary ID' ENTMAP OFF COLUMN qualifier_id1 FORMAT a75 HEADING 'Module Name' ENTMAP OFF COLUMN qualifier_id2 FORMAT a75 HEADING 'Action Name' ENTMAP OFF COLUMN waits FORMAT a75 HEADING 'Waits?' ENTMAP OFF COLUMN binds FORMAT a75 HEADING 'Binds?' ENTMAP OFF COLUMN instance_name_print FORMAT a75 HEADING 'Instance_Name' ENTMAP OFF SELECT con_id,'
') || '
') || '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - ENABLED AGGREGATIONS - | -- +----------------------------------------------------------------------------+ prompt prompt Enabled Aggregations
prompt Statistics Aggregation FROM View DBA_ENABLED_AGGREGATIONS. prompt
prompt Statistics aggregation is enabled using the DBMS_MONITOR package AND the following procedures. prompt Note that statistics gathering is global for the database AND is persistent across instance starts prompt AND restarts. prompt
prompt Hint: While the DBA_ENABLED_AGGREGATIONS provides global statistics for currently enabled prompt statistics, several other views can be used to query statistics aggregation values: V$CLIENT_STATS, prompt V$SERVICE_STATS, V$SERV_MOD_ACT_STATS, AND V$SERVICEMETRIC. CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN aggregation_type FORMAT a75 HEADING 'Aggregation Type' ENTMAP OFF COLUMN primary_id FORMAT a75 HEADING 'Primary ID' ENTMAP OFF COLUMN qualifier_id1 FORMAT a75 HEADING 'Module Name' ENTMAP OFF COLUMN qualifier_id2 FORMAT a75 HEADING 'Action Name' ENTMAP OFF SELECT con_id,'
') || '
') || '
') || '
-- +----------------------------------------------------------------------------+ -- | - ASH SNAPSHOT SETTINGS - | -- +----------------------------------------------------------------------------+ prompt prompt ASH
prompt ● (7) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a75 HEADING 'Instance_Name' ENTMAP OFF COLUMN end_interval_time FORMAT a140 HEADING ' End_Interval_Time ' ENTMAP OFF COLUMN begin_interval_time FORMAT a140 HEADING ' Begin_Interval_Time ' ENTMAP OFF COLUMN startup_time FORMAT a180 HEADING ' STARTUP_TIME ' ENTMAP OFF COLUMN elapsed_time FORMAT 999,999,999.99 HEADING 'Elapsed Time (min)' ENTMAP OFF COLUMN db_time FORMAT 999,999,999.99 HEADING 'DB Time (min)' ENTMAP OFF COLUMN pct_db_time FORMAT a75 HEADING '% DB Time' ENTMAP OFF COLUMN cpu_time FORMAT 999,999,999.99 HEADING 'CPU Time (min)' ENTMAP OFF COLUMN RETENTION FORMAT a140 HEADING ' RETENTION ' ENTMAP OFF COLUMN ash_report FORMAT a500 HEADING ' ash_report ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT d.INSTANCE_NUMBER inst_id, d.dbid, (SELECT (nb.snap_interval) (SELECT (nb.retention) TO_CHAR(d.startup_time, 'YYYY-MM-DD HH24:MI:SS.ff') startup_time, TO_CHAR(d.begin_interval_time, 'YYYY-MM-DD HH24:MI:SS.ff') begin_interval_time, TO_CHAR(d.end_interval_time, 'YYYY-MM-DD HH24:MI:SS.ff') end_interval_time, (d.flush_elapsed) flush_elapsed, d.snap_level, d.error_count, d.snap_flag, 'SELECT * FROM table(dbms_workload_repository.ash_report_html(' || d.dbid || ',' || d.instance_number || ', (SELECT a.end_interval_time ') , (SELECT a.end_interval_time (DENSE_RANK() OVER(partition by instance_number ORDER BY d.instance_number, WHERE d.end_interval_time > sysdate - 7 WHERE t.rk <= 50 prompt
SET DEFINE ON prompt prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - ADDM SNAPSHOT SETTINGS - | -- +----------------------------------------------------------------------------+ prompt prompt ADDM
alter session set nls_language='SIMPLIFIED CHINESE'; DECLARE task_name VARCHAR2(50) := 'HEALTH_CHECK_BY_LHR'; task_desc VARCHAR2(50) := 'HEALTH_CHECK_BY_LHR'; task_id NUMBER; begin begin dbms_advisor.delete_task(task_name); exception WHEN others then null; end; dbms_advisor.create_task('ADDM', task_id, task_name, task_desc, null); dbms_advisor.set_task_parameter(task_name, 'INSTANCE', &_instance_number); dbms_advisor.set_task_parameter(task_name, 'DB_ID', &_dbid); dbms_advisor.execute_task(task_name); exception WHEN others then null; END; / prompt prompt NOTE: SQL: SELECT dbms_advisor.get_task_report('HEALTH_CHECK_BY_LHR', 'TEXT', 'ALL') addm_results FROM DUAL; SET MARKUP html TABLE 'width="60%" border="1" cellspacing="0px" style="border-collapse:collapse;" ' SELECT '' addm_results FROM DUAL; SET MARKUP html TABLE 'width="auto" border="1" cellspacing="0px" style="border-collapse:collapse;" ' alter session set nls_language='&_nls_language'; prompt prompt NOTE: ADDM [Next Item] [BACK]
alter session set nls_language='AMERICAN'; SELECT '
' || dbms_advisor.get_task_report('HEALTH_CHECK_BY_LHR', 'TEXT', 'ALL') || '' addm_results FROM DUAL; alter session set nls_language='&_nls_language'; -- prompt
prompt
host echo " . . . ." prompt prompt
prompt NOTE: sysx$bh,SQL: CREATE OR REPLACE VIEW bh AS SELECT * FROM sys.x$bh; create or replace public synonym x$bh for bh; prompt NOTE: If this section runs slowly, gather system stats before executing:exec dbms_stats.gather_dictionary_stats; exec dbms_stats.gather_fixed_objects_stats; prompt CLEAR COLUMNS COMPUTES SET DEFINE OFF prompt ● () SELECT /*+rule */ e.CON_ID, e.owner, e.segment_name, e.segment_type, sum(b.tch) sum_tch FROM cdb_extents e, (SELECT * FROM (SELECT con_id, addr, ts#, file#, dbarfil, dbablk, tch FROM SYS.X$BH ORDER BY tch DESC) WHERE ROWNUM <= 10) b WHERE e.CON_ID= b.con_id and e.relative_fno = b.dbarfil AND e.block_id <= b.dbablk AND e.block_id + e.blocks > b.dbablk AND e.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') GROUP BY e.CON_ID, e.owner, e.segment_name, e.segment_type ORDER BY e.CON_ID,sum_tch desc; prompt prompt ● (,) SELECT /*+rule */ distinct e.con_id,e.owner, e.segment_name, e.segment_type, dbablk,b.tch FROM cdb_extents e, (SELECT * FROM (SELECT con_id,addr, ts#, file#, dbarfil, dbablk, tch FROM SYS.X$BH ORDER BY tch DESC) WHERE ROWNUM <= 10) b WHERE e.con_id=b.con_id and e.relative_fno = b.dbarfil AND e.block_id <= b.dbablk AND e.block_id + e.blocks > b.dbablk AND e.owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ORDER BY e.con_id, tch desc; prompt
host echo " . . ." prompt prompt prompt
prompt
prompt ● Oracle 10g:106,8;(106). prompt ● Oracle 11gand its:102,4;62,62,20. CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN NEXT_START_DATE FORMAT a140 HEADING ' NEXT_START_DATE ' ENTMAP OFF COLUMN LAST_START_DATE FORMAT a140 HEADING ' LAST_START_DATE ' ENTMAP OFF SET DEFINE ON SELECT C.* FROM CDB_AUTOTASK_CLIENT C ORDER BY C.CON_ID; prompt ● SELECT A.CON_ID, A.WINDOW_NAME, TO_CHAR(WINDOW_NEXT_TIME, 'YYYY-MM-DD HH24:MI:SS') WINDOW_NEXT_TIME, WINDOW_ACTIVE, AUTOTASK_STATUS, OPTIMIZER_STATS, SEGMENT_ADVISOR, SQL_TUNE_ADVISOR, --HEALTH_MONITOR, B.REPEAT_INTERVAL, B.DURATION, B.ENABLED, B.RESOURCE_PLAN FROM CDB_AUTOTASK_WINDOW_CLIENTS A, (SELECT T1.CON_ID, T1.WINDOW_NAME, T1.REPEAT_INTERVAL, T1.DURATION, T1.ENABLED, T1.RESOURCE_PLAN FROM CDB_SCHEDULER_WINDOWS T1, CDB_SCHEDULER_WINGROUP_MEMBERS T2 WHERE T1.WINDOW_NAME = T2.WINDOW_NAME AND T1.CON_ID = T2.CON_ID AND T2.WINDOW_GROUP_NAME IN ('MAINTENANCE_WINDOW_GROUP', 'BSLN_MAINTAIN_STATS_SCHED')) B WHERE A.WINDOW_NAME = B.WINDOW_NAME AND A.CON_ID = B.CON_ID ORDER BY A.CON_ID; prompt ● JOB CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN ACTUAL_START_DATE FORMAT a140 HEADING ' ACTUAL_START_DATE ' ENTMAP OFF COLUMN LOG_DATE FORMAT a140 HEADING ' LOG_DATE ' ENTMAP OFF COLUMN RUN_DURATION FORMAT a140 HEADING ' RUN_DURATION ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT n.CON_ID, JRD.LOG_ID, JRD.JOB_NAME, N.JOB_CLASS, TO_CHAR(JRD.ACTUAL_START_DATE, 'YYYY-MM-DD HH24:MI:SS') ACTUAL_START_DATE, TO_CHAR(JRD.LOG_DATE, 'YYYY-MM-DD HH24:MI:SS') LOG_DATE, JRD.STATUS, JRD.ERROR#, JRD.RUN_DURATION, JRD.ADDITIONAL_INFO FROM cdb_SCHEDULER_JOB_LOG N, cdb_SCHEDULER_JOB_RUN_DETAILS JRD WHERE N.LOG_ID = JRD.LOG_ID and n.CON_ID = jrd.CON_ID AND N.JOB_NAME LIKE 'ORA$AT_OS_OPT_%' and JRD.ACTUAL_START_DATE>=sysdate-15 and jrd.STATUS<>'SUCCEEDED' ORDER BY jrd.log_id DESC) WHERE ROWNUM <= 50; prompt
-- +----------------------------------------------------------------------------+ -- | - OBJECTS WITHOUT STATISTICS - | -- +----------------------------------------------------------------------------+ prompt prompt Objects Without Statistics
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN owner FORMAT a95 HEAD 'Owner' ENTMAP OFF COLUMN object_type FORMAT a20 HEAD 'Object Type' ENTMAP OFF COLUMN count FORMAT 999,999,999,999 HEAD 'Count' ENTMAP OFF -- BREAK ON report ON owner COMPUTE count LABEL 'Total: ' OF object_name ON report SELECT a.con_id, '
prompt prompt [Next Item]
prompt NOTE: 1 prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF -- BREAK ON report COMPUTE SUM label 'Total:' OF counts never_analyze expired_analyze ON report SELECT CON_ID,OWNER, count(1) counts, sum(case WHEN d.last_analyzed is null then 1 else 0 end) never_analyze, sum(case WHEN d.last_analyzed IS NOT NULL then 1 else 0 end) expired_analyze FROM (SELECT CON_ID,owner, table_name, PARTITION_NAME, OBJECT_TYPE, GLOBAL_STATS, last_analyzed FROM (SELECT t.con_id, owner, table_name, t.PARTITION_NAME, t.OBJECT_TYPE, t.GLOBAL_STATS, t.last_analyzed, DENSE_RANK() over(ORDER BY last_analyzed) rn FROM cdb_tab_statistics t WHERE (t.last_analyzed is null or t.last_analyzed < SYSDATE - 15) AND table_name NOT LIKE 'BIN$%' AND table_name NOT LIKE '%TMP%' AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND t.SUBPARTITION_NAME is null AND (t.con_id,t.OWNER, t.TABLE_NAME) in (SELECT dtm.con_id, dtm.table_owner, dtm.table_name FROM cdb_tab_modifications dtm WHERE dtm.inserts > 100 or dtm.updates > 100 or dtm.deletes > 100)) WHERE (rn <= 50 or LAST_ANALYZED is null) ORDER BY OWNER, table_name, PARTITION_NAME) d GROUP BY CON_ID,OWNER ORDER BY CON_ID,OWNER,counts desc; prompt prompt ●
prompt NOTE: 1100, CLEAR COLUMNS COMPUTES SET DEFINE OFF column GLOBAL_STATS format a15 SELECT CON_ID,owner, table_name, PARTITION_NAME, OBJECT_TYPE, GLOBAL_STATS, last_analyzed FROM (SELECT CON_ID, owner, table_name, t.PARTITION_NAME, t.OBJECT_TYPE, t.GLOBAL_STATS, t.last_analyzed, DENSE_RANK() over(ORDER BY last_analyzed) rn FROM CDB_tab_statistics t WHERE (t.last_analyzed is null or t.last_analyzed < SYSDATE - 15) AND table_name NOT LIKE 'BIN$%' AND table_name NOT LIKE '%TMP%' AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') AND t.SUBPARTITION_NAME is null AND (T.CON_ID,t.OWNER, t.TABLE_NAME) in (SELECT DTM.CON_ID,dtm.table_owner, dtm.table_name FROM CDB_tab_modifications dtm WHERE dtm.inserts > 100 or dtm.updates > 100 or dtm.deletes > 100)) WHERE (rn <= 100 or LAST_ANALYZED is null) ORDER BY CON_ID,OWNER, table_name, PARTITION_NAME; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT CON_ID,owner, table_name, t.last_analyzed, t.num_rows, t.blocks FROM CDB_tables t where t.temporary = 'Y' AND last_analyzed is null AND owner NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ; prompt
prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT CON_ID, T.OWNER index_owner, T.TABLE_OWNER, T.OBJECT_TYPE, COUNT(1) COUNTS FROM (SELECT CON_ID,D.OWNER, D.INDEX_NAME, D.TABLE_OWNER, D.TABLE_NAME, D.PARTITION_NAME, D.SUBPARTITION_NAME, D.OBJECT_TYPE FROM CDB_IND_STATISTICS D WHERE STATTYPE_LOCKED = 'ALL' AND D.OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') UNION ALL SELECT CON_ID,'', '', D.OWNER, D.TABLE_NAME, D.PARTITION_NAME, D.SUBPARTITION_NAME, D.OBJECT_TYPE FROM CDB_TAB_STATISTICS D WHERE STATTYPE_LOCKED = 'ALL' AND D.OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ) T GROUP BY CON_ID,T.OWNER, T.TABLE_OWNER, T.OBJECT_TYPE ORDER BY CON_ID,T.OBJECT_TYPE, COUNTS DESC; prompt prompt ●
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM ( SELECT CON_ID,D.OWNER, D.INDEX_NAME, D.TABLE_OWNER, D.TABLE_NAME, D.PARTITION_NAME, D.SUBPARTITION_NAME, D.OBJECT_TYPE, DENSE_RANK() OVER(PARTITION BY TABLE_OWNER ORDER BY d.num_rows DESC) RN FROM CDB_IND_STATISTICS D WHERE STATTYPE_LOCKED = 'ALL' AND D.OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') UNION ALL SELECT CON_ID,'', '', D.OWNER, D.TABLE_NAME, D.PARTITION_NAME, D.SUBPARTITION_NAME, D.OBJECT_TYPE, DENSE_RANK() OVER(PARTITION BY OWNER ORDER BY d.num_rows DESC) RN FROM CDB_TAB_STATISTICS D WHERE STATTYPE_LOCKED = 'ALL' AND D.OWNER NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ) WHERE rn<=5; prompt
-- +============================================================================+ -- | | -- | <<<<< SESSIONS >>>>> | -- | | -- +============================================================================+ host echo " . . ." prompt prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - CURRENT SESSIONS - | -- +----------------------------------------------------------------------------+ prompt prompt Session Overview()
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a45 HEADING 'Instance_Name' ENTMAP OFF COLUMN thread_number_print FORMAT a45 HEADING 'Thread Number' ENTMAP OFF COLUMN count FORMAT a45 HEADING 'Current No. of Processes' ENTMAP OFF COLUMN value FORMAT a45 HEADING 'Max No. of Processes' ENTMAP OFF COLUMN pct_usage FORMAT a45 HEADING '% Usage' ENTMAP OFF SELECT '
-- +----------------------------------------------------------------------------+ -- | - USER SESSION MATRIX - | -- +----------------------------------------------------------------------------+ prompt prompt ()
prompt User sessions (excluding SYS AND background processes) CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN instance_name_print FORMAT a75 HEADING 'Instance_Name' ENTMAP OFF COLUMN thread_number_print FORMAT a75 HEADING 'Thread Number' ENTMAP OFF COLUMN username FORMAT a79 HEADING 'Oracle User' ENTMAP OFF COLUMN num_user_sess FORMAT 999,999,999,999 HEADING 'Total Number of Logins' ENTMAP OFF COLUMN count_a FORMAT 999,999,999 HEADING 'Active Logins' ENTMAP OFF COLUMN count_i FORMAT 999,999,999 HEADING 'Inactive Logins' ENTMAP OFF COLUMN count_k FORMAT 999,999,999 HEADING 'Killed Logins' ENTMAP OFF SET DEFINE ON -- BREAK ON report ON instance_name_print ON thread_number_print SELECT '
host echo " ACTIVE. . . ." prompt prompt ACTIVE
prompt ● ACTIVE()
CLEAR COLUMNS COMPUTES SET DEFINE OFF FROM (SELECT n.con_id, n.instance_number inst_id, n.session_id, n.session_serial#, TO_CHAR(n.sample_time, 'YYYY-MM-DD') TIME FROM CDB_hist_active_sess_history n WHERE n.sample_time >= sysdate - 7 GROUP BY n.con_id, n.instance_number, n.session_id, n.session_serial#, TO_CHAR(n.sample_time, 'YYYY-MM-DD')) t prompt prompt ● ACTIVE()
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT con_id, a.inst_id inst_id, SUBSTR(SAMPLE_TIME, 1, 10) Day, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '00', 1, 0)) H00, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '01', 1, 0)) H01, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '02', 1, 0)) H02, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '03', 1, 0)) H03, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '04', 1, 0)) H04, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '05', 1, 0)) H05, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '06', 1, 0)) H06, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '07', 1, 0)) H07, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '08', 1, 0)) H08, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '09', 1, 0)) H09, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '10', 1, 0)) H10, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '11', 1, 0)) H11, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '12', 1, 0)) H12, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '13', 1, 0)) H13, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '14', 1, 0)) H14, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '15', 1, 0)) H15, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '16', 1, 0)) H16, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '17', 1, 0)) H17, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '18', 1, 0)) H18, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '19', 1, 0)) H19, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '20', 1, 0)) H20, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '21', 1, 0)) H21, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '22', 1, 0)) H22, sum(DECODE(SUBSTR(SAMPLE_TIME, -2, 2), '23', 1, 0)) H23, COUNT(*) TOTAL FROM (SELECT n.con_id, n.instance_number inst_id, n.session_id, n.session_serial#, TO_CHAR(SAMPLE_TIME, 'YYYY-MM-DD HH24') SAMPLE_TIME FROM cdb_hist_active_sess_history n WHERE N.SAMPLE_TIME >= SYSDATE - 30 GROUP BY con_id, n.instance_number, n.session_id, n.session_serial#, TO_CHAR(SAMPLE_TIME, 'YYYY-MM-DD HH24')) a GROUP BY con_id, inst_id, SUBSTR(SAMPLE_TIME, 1, 10) ORDER BY con_id, inst_id, SUBSTR(SAMPLE_TIME, 1, 10) desc; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN LOGON_TIME FORMAT a140 HEADING ' LOGON_TIME ' ENTMAP OFF COLUMN kill_session FORMAT a300 HEADING ' KILL_SESSION_SQL ' ENTMAP OFF SET DEFINE ON SELECT A.INST_ID, A.USERNAME, A.LOGON_TIME, A.STATUS, A.SID, A.SERIAL#, (SELECT NB.SPID FROM GV$PROCESS NB WHERE NB.ADDR = A.PADDR AND NB.INST_ID = A.INST_ID) SPID, (SELECT TRUNC(NB.PGA_USED_MEM / 1024 / 1024) FROM GV$PROCESS NB WHERE NB.ADDR = A.PADDR AND NB.INST_ID = A.INST_ID) PGA_USED_MEM, (A.MODULE || ' --' || A.ACTION || '--' || A.PROGRAM || '--' || A.CLIENT_IDENTIFIER || ' --' || A.CLIENT_INFO || '--' || A.SERVICE_NAME) SESSION_TYPE, A.OSUSER, ROUND(A.LAST_CALL_ET / 60 / 60, 2) TOTAL_H, 'ALTER SYSTEM DISCONNECT SESSION ''' || A.SID || ',' || A.SERIAL# || ''' IMMEDIATE' KILL_SESSION FROM GV$SESSION A WHERE A.STATUS IN ('INACTIVE') AND A.USERNAME IS NOT NULL AND A.USERNAME NOT IN ('SYS') AND A.LAST_CALL_ET >= 60 * 60 * 10 ORDER BY A.INST_ID, A.LAST_CALL_ET DESC, A.USERNAME, A.LOGON_TIME; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT * FROM (SELECT T1.INST_ID, T1.SID, T1.VALUE, T2.NAME, DENSE_RANK() OVER(ORDER BY T1.VALUE DESC) RANK_ORDER FROM GV$SESSTAT T1, GV$STATNAME T2 WHERE T2.NAME LIKE '%user commits%' AND T1.STATISTIC# = T2.STATISTIC# AND T1.INST_ID = T2.INST_ID AND VALUE >= 10000) WHERE RANK_ORDER <= 20 ORDER BY INST_ID, VALUE DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT t.*, s.sid, s.serial#, s.machine, s.program, s.osuser FROM (SELECT b.con_id, b.INST_ID, c.USERNAME, a.event, TO_CHAR(a.cnt) AS seconds, a.sql_id, --dbms_lob.substr(b.sql_fulltext, 100, 1) sqltext , b.SQL_TEXT FROM (SELECT ROWNUM rn, t.* FROM (SELECT s.con_id, s.INST_ID, DECODE(s.session_state, 'WAITING', s.event, 'Cpu + Wait For Cpu') Event, s.sql_id, s.user_id, COUNT(*) CNT WHERE sample_time > SYSDATE - 15 / 1440 GROUP BY s.con_id, INST_ID, s.user_id, DECODE(s.session_state, 'WAITING', s.event, 'Cpu + Wait For Cpu'), s.sql_id ORDER BY CNT DESC) t WHERE ROWNUM < 20) a, gv$sqlarea b, cdb_users c WHERE a.sql_id = b.sql_id AND a.user_id = c.user_id AND a.INST_ID = b.INST_ID and b.con_id=c.con_id and a.con_id=b.con_id AND c.username NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ORDER BY CNT DESC) t, gv$session s WHERE t.sql_id = s.sql_id(+) AND t.INST_ID = s.INST_ID(+) and t.con_id=s.con_id(+) ORDER BY t.con_id,t.INST_ID ; prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT /*+ RULE */ o.con_id, INST_ID, LS.OSUSER OS_USER_NAME, LS.USERNAME USER_NAME, DECODE(LS.TYPE, 'RW', 'Row wait enqueue lock', 'TM', 'DML enqueue lock', 'TX', 'Transaction enqueue lock', 'UL', 'User supplied lock') LOCK_TYPE, O.OBJECT_NAME OBJECT, DECODE(LS.LMODE, 1, NULL, 2, 'Row Share', 3, 'Row Exclusive', 4, 'Share', 5, 'Share Row Exclusive', 6, 'Exclusive', NULL) LOCK_MODE, O.OWNER, LS.SID, LS.SERIAL# SERIAL_NUM, LS.ID1, LS.ID2 FROM cdb_OBJECTS O, (SELECT s.con_id, s.INST_ID, S.OSUSER, S.USERNAME, L.TYPE, L.LMODE, S.SID, S.SERIAL#, L.ID1, L.ID2 FROM gV$SESSION S, gV$LOCK L WHERE S.SID = L.SID AND s.INST_ID=l.INST_ID and s.con_id=l.con_id) LS WHERE O.OBJECT_ID = LS.ID1 and o.con_id=ls.con_id AND O.OWNER <> 'SYS' ORDER BY o.con_id, INST_ID, O.OWNER, O.OBJECT_NAME; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT /*+no_merge(a) no_merge(b) */ a.INST_ID, b.INST_ID, (SELECT username FROM v$session WHERE sid = a.sid) blocker, a.sid, 'is blocking', (SELECT username FROM v$session WHERE sid = b.sid) blockee, b.sid FROM gv$lock a, gv$lock b WHERE a.block = 1 AND b.request > 0 AND a.id1 = b.id1 AND a.id2 = b.id2 ORDER BY a.sid; prompt
prompt ● v$SESSION
prompt NOTE: DBA_DML_LOCKS,DBA_DDL_LOCKS,V$LOCK,DBA_LOCK,V$LOCKED_OBJECT.V$LOCKED_OBJECTDML,DDL.V$LOCKDBA_LOCKSDBA_LOCK,DBA_LOCKSDBA_LOCK synonym. SELECT A.CON_ID, A.INST_ID, A.TADDR, A.LOCKWAIT, A.ROW_WAIT_OBJ#, A.ROW_WAIT_FILE#, A.ROW_WAIT_BLOCK#, A.ROW_WAIT_ROW#, (SELECT D.OWNER || '|' || D.OBJECT_NAME || '|' || D.OBJECT_TYPE FROM CDB_OBJECTS D WHERE D.OBJECT_ID = A.ROW_WAIT_OBJ# AND D.CON_ID=A.CON_ID AND ROWNUM <= 1) OBJECT_NAME, A.EVENT, A.P1, A.P2, A.P3, CHR(BITAND(P1, -16777216) / 16777215) || CHR(BITAND(P1, 16711680) / 65535) "LOCK", BITAND(P1, 65535) "MODE", TRUNC(P2 / POWER(2, 16)) AS XIDUSN, BITAND(P2, TO_NUMBER('FFFF', 'XXXX')) + 0 AS XIDSLOT, P3 XIDSQN, A.SID, A.BLOCKING_SESSION, A.SADDR, DBMS_ROWID.ROWID_CREATE(1, 77669, 8, 2799, 0) REQUEST_ROWID, (SELECT B.SQL_TEXT FROM GV$SQL B WHERE B.SQL_ID = NVL(A.SQL_ID, A.PREV_SQL_ID) AND B.CON_ID=A.CON_ID AND ROWNUM <= 1) SQL_TEXT FROM GV$SESSION A WHERE A.BLOCKING_SESSION IS NOT NULL ORDER BY A.CON_ID, A.INST_ID; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT D.CON_ID, d.INST_ID, sid, COUNT(*) cnt FROM gv$open_cursor d GROUP BY D.CON_ID,d.INST_ID, sid HAVING COUNT(*) >= 1000 ORDER BY D.CON_ID, d.INST_ID, cnt DESC; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT sl.INST_ID, s.client_info, sl.message, sl.sid, sl.serial#, p.spid, round(sl.sofar / sl.totalwork * 100, 2) "% Complete" FROM gv$session_longops sl, gv$session s, gv$process p WHERE p.addr = s.paddr AND sl.sid = s.sid AND sl.serial# = s.serial# AND sl.INST_ID = s.INST_ID AND sl.INST_ID = p.INST_ID AND opname LIKE 'RMAN%' AND opname NOT LIKE '%aggregate%' AND totalwork != 0 AND sofar <> totalwork; prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT count(*) ,round(sum(sharable_mem)/1024/1024,2) sharable_mem_M FROM v$db_object_cache a; prompt
prompt prompt PGATop Consuming Processes
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN LOGON_TIME FORMAT a160 HEADING ' LOGON_TIME ' ENTMAP OFF COLUMN kill_session FORMAT a500 HEADING ' kill_session ' ENTMAP OFF SET DEFINE ON SELECT * FROM (SELECT p.INST_ID, p.spid, p.pid, s.sid, s.serial#, s.status, trunc(p.pga_alloc_mem/1024/1024) pga_alloc_mem_m, s.username, s.osuser, s.program, s.SQL_ID FROM gv$process p, gv$session s WHERE s.paddr(+) = p.addr AND p.INST_ID = s.INST_ID AND s.USERNAME not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ORDER BY p.pga_alloc_mem DESC) WHERE ROWNUM < 21 ORDER BY INST_ID, pga_alloc_mem_m DESC; SELECT a.INST_ID, A.USERNAME, A.LOGON_TIME, A.STATUS, A.SID, A.SERIAL#, SPID, PGA_USED_MEM PGA_USED_MEM, (A.MODULE || ' --' || A.ACTION || '--' || A.PROGRAM || '--' || a.CLIENT_IDENTIFIER || ' --' || a.CLIENT_INFO || '--' || a.SERVICE_NAME) session_type, A.OSUSER, round(a.LAST_CALL_ET / 60 / 60, 2) total_h, 'ALTER SYSTEM DISCONNECT SESSION ''' || a.SID || ',' || a.serial# || ''' IMMEDIATE' kill_session FROM gv$session A, (SELECT NNB.ADDR, NNB.INST_ID, trunc(PGA_USED_MEM / 1024 / 1024) PGA_USED_MEM, NNB.BACKGROUND, nnb.spid, DENSE_RANK() OVER(ORDER BY NNB.PGA_USED_MEM DESC) rank_order FROM gv$process NNB WHERE NNB.BACKGROUND is null) B WHERE B.ADDR = a.PADDR AND B.INST_ID = a.INST_ID AND B.PGA_USED_MEM > 1 AND rank_order <= 10 AND a.USERNAME not in ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') ORDER BY a.INST_ID, rank_order DESC, a.USERNAME, a.LOGON_TIME; prompt
prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT A.INST_ID, sum(physical_reads) physical_reads, sum(db_block_gets) db_block_gets, TO_CHAR(sum(consistent_gets)) consistent_gets, round(DECODE(DECODE((sum(db_block_gets) + sum(consistent_gets)), 0, 0, (sum(physical_reads) / (sum(db_block_gets) + sum(consistent_gets)))), 0, 0, 1 - DECODE((sum(db_block_gets) + sum(consistent_gets)), 0, 0, (sum(physical_reads) / (sum(db_block_gets) + sum(consistent_gets))))), 4) * 100 || '%' "Hit Ratio" FROM Gv$buffer_pool_statistics A GROUP BY A.INST_ID; prompt
prompt NOTE: If less than95%,,or Adjust Database Parametersshared_pool_size CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT a.inst_id, sum(gets) gets, sum(gethits) gethits, round(sum(gethits) * 100 / sum(gets),2) gets_Hit_Ratio, sum(pins) pins, sum(pinhits) pinhits, round(sum(pinhits) *100 / sum(pins),2) Pins_Hit_Ratio FROM gv$librarycache a group by a.inst_id; SELECT a.inst_id,namespace , sum(gets) gets, sum(gethits) gethits, round(DECODE(sum(gets),0,0,sum(gethits)*100 / sum(gets)),2) gets_Hit_Ratio, sum(pins) pins, sum(pinhits) pinhits, round(DECODE(sum(pins),0,0,sum(pinhits)*100 / sum(pins)),2) Pins_Hit_Ratio, sum(RELOADS) RELOADS, sum(INVALIDATIONS) INVALIDATIONS FROM gv$librarycache a GROUP BY a.inst_id,namespace ORDER BY namespace; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT A.INST_ID, ROUND((SUM(GETS-GETMISSES-USAGE-FIXED))/SUM(GETS)*100,2) DATA_DICTIONARY_CACHE FROM GV$ROWCACHE A GROUP BY A.INST_ID; SELECT A.INST_ID, parameter , sum(gets) , sum(getmisses) , 100*sum(gets - getmisses) / sum(gets) pct_succ_gets , sum(modifications) updates FROM GV$ROWCACHE A WHERE gets > 10 GROUP BY A.INST_ID, parameter; prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SELECT A.INST_ID, sum(gets), sum(misses), round(1 - sum(misses) / sum(gets), 4) FROM Gv$latch A GROUP BY A.INST_ID; prompt
host echo " . . ." prompt prompt
prompt
prompt ● Wait Events (Current)
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT a.INST_ID, a.WAIT_CLASS#, a.WAIT_CLASS, a.EVENT, COUNT(1) counts FROM gv$session a WHERE a.WAIT_CLASS <> 'Idle' GROUP BY a.INST_ID, a.WAIT_CLASS#, a.WAIT_CLASS, a.EVENT ORDER BY a.INST_ID, counts DESC; prompt
prompt ● (cdb_hist_active_sess_history)
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN END_INTERVAL_TIME FORMAT a160 HEADING ' END_INTERVAL_TIME ' ENTMAP OFF COLUMN BEGIN_INTERVAL_TIME FORMAT a140 HEADING ' BEGIN_INTERVAL_TIME ' ENTMAP OFF COLUMN STARTUP_TIME FORMAT a160 HEADING ' STARTUP_TIME ' ENTMAP OFF COLUMN EVENT FORMAT a300 HEADING ' EVENT ' ENTMAP OFF COLUMN SESSION_INFO FORMAT a300 HEADING ' SESSION_INFO ' ENTMAP OFF SET DEFINE ON SELECT V.CON_ID, V.INSTANCE_NUMBER, TO_CHAR(S.BEGIN_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') BEGIN_INTERVAL_TIME, TO_CHAR(S.END_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') END_INTERVAL_TIME, TO_CHAR(S.STARTUP_TIME, 'YYYY-MM-DD HH24:MI:SS') STARTUP_TIME, EVENT, WAIT_CLASS, SESSION_STATE, SESSION_TYPE, SESSION_INFO, SQL_ID, COUNTS FROM (SELECT D.CON_ID, D.INSTANCE_NUMBER, D.EVENT, D.WAIT_CLASS, D.SESSION_STATE, D.SESSION_TYPE, D.PROGRAM || ' --' || D.MODULE || '--' || D.ACTION SESSION_INFO, D.SQL_ID, COUNT(1) COUNTS, DENSE_RANK() OVER(PARTITION BY D.INSTANCE_NUMBER ORDER BY COUNT(1) DESC) RN FROM CDB_HIST_ACTIVE_SESS_HISTORY D WHERE D.EVENT IS NOT NULL AND D.WAIT_CLASS <> 'Idle' AND D.SQL_ID IS NOT NULL GROUP BY D.CON_ID, D.INSTANCE_NUMBER, D.EVENT, D.WAIT_CLASS, D.SESSION_STATE, D.SESSION_TYPE, D.SQL_ID, (D.PROGRAM || ' --' || D.MODULE || '--' || D.ACTION)) V, CDB_HIST_SNAPSHOT S WHERE V.INSTANCE_NUMBER = S.INSTANCE_NUMBER AND RN <= 20 AND COUNTS > 20 prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF prompt
-- +============================================================================+ -- | | -- | <<<<< NETWORKING >>>>> | -- | | -- +============================================================================+ prompt prompt
prompt Dispatcher rate CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN name HEADING 'Name' ENTMAP OFF COLUMN avg_loop_rate HEADING 'Avg|Loop|Rate' ENTMAP OFF COLUMN avg_event_rate HEADING 'Avg|Event|Rate' ENTMAP OFF COLUMN avg_events_per_loop HEADING 'Avg|Events|Per|Loop' ENTMAP OFF COLUMN avg_msg_rate HEADING 'Avg|Msg|Rate' ENTMAP OFF COLUMN avg_svr_buf_rate HEADING 'Avg|Svr|Buf|Rate' ENTMAP OFF COLUMN avg_svr_byte_rate HEADING 'Avg|Svr|Byte|Rate' ENTMAP OFF COLUMN avg_svr_byte_per_buf HEADING 'Avg|Svr|Byte|Per|Buf' ENTMAP OFF COLUMN avg_clt_buf_rate HEADING 'Avg|Clt|Buf|Rate' ENTMAP OFF COLUMN avg_clt_byte_rate HEADING 'Avg|Clt|Byte|Rate' ENTMAP OFF COLUMN avg_clt_byte_per_buf HEADING 'Avg|Clt|Byte|Per|Buf' ENTMAP OFF COLUMN avg_buf_rate HEADING 'Avg|Buf|Rate' ENTMAP OFF COLUMN avg_byte_rate HEADING 'Avg|Byte|Rate' ENTMAP OFF COLUMN avg_byte_per_buf HEADING 'Avg|Byte|Per|Buf' ENTMAP OFF COLUMN avg_in_connect_rate HEADING 'Avg|In|Connect|Rate' ENTMAP OFF COLUMN avg_out_connect_rate HEADING 'Avg|Out|Connect|Rate' ENTMAP OFF COLUMN avg_reconnect_rate HEADING 'Avg|Reconnect|Rate' ENTMAP OFF SELECT name, avg_loop_rate, avg_event_rate, avg_events_per_loop, avg_msg_rate, avg_svr_buf_rate, avg_svr_byte_rate, avg_svr_byte_per_buf, avg_clt_buf_rate, avg_clt_byte_rate, avg_clt_byte_per_buf, avg_buf_rate, avg_byte_rate, avg_byte_per_buf, avg_in_connect_rate, avg_out_connect_rate, avg_reconnect_rate FROM v$dispatcher_rate ORDER BY name; COLUMN protocol HEADING 'Protocol' ENTMAP OFF COLUMN total_busy_rate HEADING 'Total Busy Rate' ENTMAP OFF prompt Dispatcher busy rate SELECT a.network protocol , (SUM(a.BUSY) / (SUM(a.BUSY) + SUM(a.IDLE))) total_busy_rate FROM v$dispatcher a GROUP BY a.network; prompt
-- +----------------------------------------------------------------------------+ -- | - MTS DISPATCHER RESPONSE QUEUE WAIT STATS - | -- +----------------------------------------------------------------------------+ prompt prompt ● MTS Dispatcher Response Queue Wait Stats
CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN type HEADING 'Type' ENTMAP OFF COLUMN avg_wait HEADING 'Avg Wait Time Per Response' ENTMAP OFF SELECT a.type, DECODE(SUM(a.totalq), 0, 'NO RESPONSES', SUM(a.wait) / SUM(a.totalq) || ' HUNDREDTHS OF SECONDS') avg_wait FROM v$queue a WHERE a.type = 'DISPATCHER' GROUP BY a.type; prompt
-- +----------------------------------------------------------------------------+ -- | - MTS SHARED SERVER WAIT STATISTICS - | -- +----------------------------------------------------------------------------+ prompt prompt ● MTS Shared Server Wait Statistics
CLEAR COLUMNS COMPUTES SET DEFINE ON COLUMN avg_wait HEADING 'Average Wait Time Per Request' ENTMAP OFF SELECT DECODE(a.totalq, 0, 'No Requests', a.wait / a.totalq || ' HUNDREDTHS OF SECONDS') avg_wait FROM v$queue a WHERE a.type = 'COMMON'; prompt
-- +============================================================================+ -- | | -- | <<<<< >>>>> | -- | | -- +============================================================================+ prompt prompt
CLEAR COLUMNS COMPUTES SET DEFINE OFF SET DEFINE ON SELECT '
' CHECK_MESSAGE_DETAIL_LINK from dual) end AS health_check_results from dual UNION ALL select case when (SELECT SUM(COUNTS) FROM (SELECT COUNT(1) COUNTS FROM CDB_DATA_FILES D WHERE D.ONLINE_STATUS = 'OFFLINE' UNION ALL SELECT COUNT(1) FROM CDB_TEMP_FILES D WHERE D.STATUS = 'OFFLINE')) > 0 then (select 2 || '|' || 1 || '|' || 'Inspection Service Summary..' || '|' || 'OFFLINEhas datafiles in bad state; immediate fix recommended' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(1) FROM V$ASM_DISKGROUP DI WHERE (DI.TOTAL_MB - DI.FREE_MB) / DI.TOTAL_MB >= 0.95) > 0 then (select 3 || '|' || 3 || '|' || 'Inspection Service Summary.ASM' || '|' || 'ASM' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT SUM(COUNTS) FROM (SELECT COUNT(1) COUNTS FROM CDB_SCHEDULER_JOB_LOG D WHERE D.OWNER NOT like '%SYS%' AND D.STATUS <> 'SUCCEEDED' AND D.LOG_DATE >= SYSDATE - 15 UNION ALL SELECT COUNT(1) FROM CDB_JOBS D WHERE D.SCHEMA_USER NOT like '%SYS%' AND D.FAILURES > 0 AND D.LAST_DATE >= SYSDATE - 15)) > 0 then (select 4 || '|' || 5 || '|' || 'Inspection Service Summary.JOB' || '|' || 'Within the Past MonthJOB,JOB' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT count(1) FROM v$backup_set) < 2 then (select 5 || '|' || 2 || '|' || 'Inspection.RMAN' || '|' || 'RMAN,' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (select count(*) from (select l.force_matching_signature, max(l.sql_id || l.child_number) max_sql_child, dense_rank() over(order by count(*) desc) ranking, count(*) counts from gv$sql l where l.force_matching_signature <> 0 and l.parsing_schema_name NOT IN ('SYS','SYSTEM','PUBLIC','MDSYS','DBSNMP','SCOTT','LHR','LHR2','DB_MONITOR','OUTLN','MGMT_VIEW','FLOWS_FILES','ORDSYS','EXFSYS','WMSYS','APPQOSSYS','APEX_030200','OWBSYS_AUDIT','ORDDATA','CTXSYS','ANONYMOUS','SYSMAN','XDB','ORDPLUGINS','OWBSYS','SI_INFORMTN_SCHEMA','OLAPSYS','ORACLE_OCM','XS$NULL','BI','PM','MDDATA','IX','SH','DIP','OE','APEX_PUBLIC_USER','HR','SPATIAL_CSW_ADMIN_USR','SPATIAL_WFS_ADMIN_USR','APEX_040200','DVSYS','LBACSYS','GSMADMIN_INTERNAL','AUDSYS','OJVMSYS','SYS$UMF','GGSYS','DBSFWUSER','DVF','GSMCATUSER','SYSBACKUP','REMOTE_SCHEDULER_AGENT','GSMUSER','SYSRAC','SYSKM','SYSDG') group by l.force_matching_signature having count(*) > 10)) > 0 then (select 6 || '|' || 2 || '|' || 'Inspection.SQL.SQL' || '|' || 'SQLlibrarycache,' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(*) FROM (SELECT AL.THREAD#, ADS.DEST_ID, ADS.DEST_NAME, MAX((SELECT ADS.TYPE || ' ' || AD.TARGET FROM V$ARCHIVE_DEST AD WHERE AD.DEST_ID = ADS.DEST_ID)) TARGET, ADS.DATABASE_MODE, ADS.STATUS, ADS.ERROR, ADS.RECOVERY_MODE, ADS.DB_UNIQUE_NAME, ADS.DESTINATION, (SELECT MAX(SEQUENCE#) FROM V$LOG NA WHERE NA.THREAD# = AL.THREAD#) CURRENT_SEQ#, MAX(SEQUENCE#) LAST_ARCHIVED, MAX(CASE WHEN AL.APPLIED = 'YES' AND ADS.TYPE <> 'LOCAL' THEN AL.SEQUENCE# END) APPLIED_SEQ#, '' APPLIED_SCN FROM (SELECT * FROM V$ARCHIVED_LOG V WHERE V.RESETLOGS_CHANGE# = (SELECT D.RESETLOGS_CHANGE# FROM V$DATABASE D)) AL, V$ARCHIVE_DEST_STATUS ADS WHERE AL.DEST_ID(+) = ADS.DEST_ID AND ADS.STATUS != 'INACTIVE' GROUP BY AL.THREAD#, ADS.DEST_ID, ADS.DEST_NAME, ADS.STATUS, ADS.ERROR, ADS.TYPE, ADS.DATABASE_MODE, ADS.RECOVERY_MODE, ADS.DB_UNIQUE_NAME, ADS.DESTINATION) WHERE TARGET NOT LIKE '%LOCAL%' AND (ERROR IS NOT NULL OR STATUS <> 'VALID' OR CURRENT_SEQ# > APPLIED_SEQ# + 2)) > 0 then (select 7 || '|' || 2 || '|' || 'Inspection.DG' || '|' || 'DG,ViewDGDetails' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(1) FROM CDB_OBJECTS WHERE OWNER NOT IN ('PUBLIC') AND STATUS <> 'VALID') > 0 then (select 8 || '|' || 4 || '|' || '.' || '|' || ',' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(1) FROM (SELECT ROUND((SUM(A.SPACE * (SELECT VALUE FROM V$PARAMETER WHERE NAME = 'db_block_size'))) / 1024 / 1024, 2) SIZE_M FROM CDB_RECYCLEBIN A) WHERE SIZE_M > 1024) > 0 then (select 9 || '|' || 4 || '|' || '..' || '|' || '' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(1) FROM CDB_HIST_ACTIVE_SESS_HISTORY D, CDB_USERS A WHERE D.USER_ID = A.USER_ID AND D.CON_ID=A.CON_ID AND USERNAME NOT LIKE '%SYS%' AND D.EVENT LIKE 'enq: SQ%') > 0 then (select 10 || '|' || 2 || '|' || '..cacheless than20' || '|' || 'cacheless than20,enq: SQ - contention' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(1) FROM gv$session A WHERE A.STATUS IN ('INACTIVE') AND A.USERNAME IS NOT NULL AND A.USERNAME not in ('SYS') AND A.LAST_CALL_ET >= 60 * 60 * 10) > 0 then (select 11 || '|' || 2 || '|' || '..10' || '|' || '10kill' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (select count(*) from (SELECT g.inst_id,sum(pinhits) / sum(pins) FROM Gv$librarycache g group by g.inst_id having sum(pinhits) / sum(pins)<0.95)) >0 then (select 12 || '|' || 2 || '|' || '.Memory Usage.' || '|' || ' 95%,,or Adjust Database Parametersshared_pool_size' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT count(1) FROM (SELECT TABLESPACE_NAME,d.CON_ID, SUM(BYTES) all_bytes FROM cdb_data_files d GROUP BY TABLESPACE_NAME,d.CON_ID) a, (SELECT TABLESPACE_NAME,d.CON_ID,SUM(BYTES) FREESIZ FROM cdb_free_space d GROUP BY TABLESPACE_NAME,d.CON_ID) b where a.TABLESPACE_NAME = b.TABLESPACE_NAME and a.con_id=b.con_id and round((a.all_bytes - b.FREESIZ) / a.all_bytes, 2) > 0.98) > 0 then (select 13 || '|' || 1 || '|' || 'Inspection Service Summary..' || '|' || 'If tablespace usage exceeds98%,consider increasing tablespace size' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT SUM(COUNTS) FROM (SELECT COUNT(1) COUNTS FROM CDB_AUTOTASK_CLIENT D WHERE CLIENT_NAME ='auto optimizer stats collection' UNION ALL SELECT COUNT(1) FROM (SELECT A.WINDOW_NAME, TO_CHAR(WINDOW_NEXT_TIME,'YYYY-MM-DD HH24:MI:SS') WINDOW_NEXT_TIME, WINDOW_ACTIVE, AUTOTASK_STATUS, OPTIMIZER_STATS, SEGMENT_ADVISOR, SQL_TUNE_ADVISOR, B.REPEAT_INTERVAL, B.DURATION, B.ENABLED, B.RESOURCE_PLAN FROM CDB_AUTOTASK_WINDOW_CLIENTS A, (SELECT T1.CON_ID, T1.WINDOW_NAME, T1.REPEAT_INTERVAL, T1.DURATION, T1.ENABLED, T1.RESOURCE_PLAN FROM CDB_SCHEDULER_WINDOWS T1, CDB_SCHEDULER_WINGROUP_MEMBERS T2 WHERE T1.WINDOW_NAME=T2.WINDOW_NAME AND T1.CON_ID=T2.CON_ID AND T2.WINDOW_GROUP_NAME IN ('MAINTENANCE_WINDOW_GROUP', 'BSLN_MAINTAIN_STATS_SCHED')) B WHERE A.WINDOW_NAME = B.WINDOW_NAME AND A.CON_ID = B.CON_ID) AA WHERE AA.AUTOTASK_STATUS = 'ENABLED')) <> (SELECT count(*)*8 FROM v$containers a WHERE a.NAME<>'PDB$SEED' AND A.OPEN_MODE='READ WRITE' ) then (select 14 || '|' || 2 || '|' || '..' || '|' || ',' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(*) FROM v$diag_alert_ext T WHERE T.MESSAGE_TEXT LIKE '%ORA-%' AND trim(t.COMPONENT_ID) = 'rdbms' and t.FILENAME LIKE '%' ||sys_context('USERENV', 'INSTANCE_NAME') || '%' AND t.ORIGINATING_TIMESTAMP >= sysdate - 7) > 0 then (select 15 || '|' || 2 || '|' || '..' || '|' || 'ora,' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(*) FROM v$pdbs a where a.OPEN_MODE in ('MOUNTED') or a.RESTRICTED='YES') > 0 then (select 16 || '|' || 2 || '|' || '..PDB' || '|' || 'PDB' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual UNION ALL select case when (SELECT COUNT(*) FROM V$CONTROLFILE a) < 2 then (select 17 || '|' || 2 || '|' || 'Inspection Service Summary..Control File' || '|' || 'Control File,Control File' || '|' || '
' CHECK_MESSAGE_DETAIL_LINK from dual) end from dual ) where SUBSTR(health_check_results, instr(health_check_results, '|', 1) + 1, 1) is not null) V; prompt
host echo AWR.... ------------------------------------------------------------------------------------------------------------------------- ------------------------------ AWR ------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------- set termout off set echo off set feedback off set verify off set wrap on set trimspool on set serveroutput off set escape off set sqlblanklines off SET MARKUP HTML OFF PREFORMAT OFF entmap on set linesize 4000 ; set pagesize 0 ; set newpage 1 ; set feed off; set heading off prompt
prompt
prompt prompt ● AWR
prompt prompt prompt
host echo ASH.... ------------------------------------------------------------------------------------------------------------------------- ------------------------------ ASH ------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------- set termout off set echo off set feedback off set verify off set wrap on set trimspool on set serveroutput off set escape off set sqlblanklines off SET MARKUP HTML OFF PREFORMAT OFF entmap on set linesize 4000 ; set pagesize 0 ; set newpage 1 ; set feed off; set heading off prompt
prompt
prompt prompt ● ASH
prompt SELECT * FROM table(dbms_workload_repository.ash_report_html(&_dbid, &_instance_number, (SELECT a.end_interval_time AND a.INSTANCE_NUMBER = &_instance_number), (SELECT a.end_interval_time AND a.INSTANCE_NUMBER = &_instance_number))); prompt prompt
host echo SQL.... ------------------------------------------------------------------------------------------------------------------------- ------------------------------ SQL ------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------- set termout off set echo off set feedback off set verify off set wrap on set trimspool on set serveroutput off set escape off set sqlblanklines off SET MARKUP HTML OFF PREFORMAT OFF entmap on set linesize 4000 ; set pagesize 0 ; set newpage 1 ; set feed off; set heading off prompt
prompt
prompt prompt ● SQL
prompt prompt prompt
host echo .... ------------------------------------------------------------------------------------------------------------------------- ------------------------------ ------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------- COLUMN date_time_end NEW_VALUE _date_time_end NOPRINT SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') date_time_end FROM dual; prompt
prompt
-- +----------------------------------------------------------------------------+ -- | - Error Checks in Report - | -- +----------------------------------------------------------------------------+ prompt
prompt
set termout off set echo off set feedback off set heading off set verify off set wrap on set trimspool on set serveroutput on set escape on set sqlblanklines on set ARRAYSIZE 500 set pagesize 50000 set linesize 32767 set numwidth 18 set long 2000000000 LONGCHUNKSIZE 100000 clear buffer computes columns alter session set NLS_DATE_FORMAT='YYYY-MM-DD HH24:mi:ss'; set termout off set heading on set markup html on spool on preformat off entmap on - head ' -
prompt NOTE: ,, CLEAR COLUMNS COMPUTES SET DEFINE OFF COLUMN username FORMAT a10 HEADING 'username' ENTMAP OFF COLUMN timestamp FORMAT a180 HEADING ' timestamp ' ENTMAP OFF SET DEFINE ON SELECT d.username, to_char(d.timestamp,'YYYY-MM-DD HH24:MI:SS') timestamp, D.SCRIPT, d.identifier, D.MESSAGE, D.STATEMENT FROM SPERRORLOG d WHERE identifier='LHR_DB_HEALTHCHECK'; prompt
SPOOL OFF set errorlogging off delete from sperrorlog where identifier='LHR_DB_HEALTHCHECK'; COMMIT; SET TERMOUT ON SET MARKUP HTML OFF PREFORMAT OFF entmap on prompt prompt Inspection(OS): &_reporttitle..html prompt Inspection! exit EXIT