2026-03-12 20:23:15
This commit is contained in:
26
timhall/monitoring/access.sql
Normal file
26
timhall/monitoring/access.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/access.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists all objects being accessed in the schema.
|
||||
-- Call Syntax : @access (schema-name or all) (object-name or all)
|
||||
-- Requirements : Access to the v$views.
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 255
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN object FORMAT A30
|
||||
|
||||
SELECT a.object,
|
||||
a.type,
|
||||
a.sid,
|
||||
b.serial#,
|
||||
b.username,
|
||||
b.osuser,
|
||||
b.program
|
||||
FROM v$access a,
|
||||
v$session b
|
||||
WHERE a.sid = b.sid
|
||||
AND a.owner = DECODE(UPPER('&1'), 'ALL', a.object, UPPER('&1'))
|
||||
AND a.object = DECODE(UPPER('&2'), 'ALL', a.object, UPPER('&2'))
|
||||
ORDER BY a.object;
|
||||
42
timhall/monitoring/active_sessions.sql
Normal file
42
timhall/monitoring/active_sessions.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/active_sessions.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all active database sessions.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @active_sessions
|
||||
-- Last Modified: 16-MAY-2019
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
|
||||
COLUMN username FORMAT A30
|
||||
COLUMN osuser FORMAT A20
|
||||
COLUMN spid FORMAT A10
|
||||
COLUMN service_name FORMAT A15
|
||||
COLUMN module FORMAT A45
|
||||
COLUMN machine FORMAT A30
|
||||
COLUMN logon_time FORMAT A20
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.osuser,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
p.spid,
|
||||
s.lockwait,
|
||||
s.status,
|
||||
s.machine,
|
||||
s.program,
|
||||
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,
|
||||
s.last_call_et AS last_call_et_secs,
|
||||
s.module,
|
||||
s.action,
|
||||
s.client_info,
|
||||
s.client_identifier
|
||||
FROM v$session s,
|
||||
v$process p
|
||||
WHERE s.paddr = p.addr
|
||||
AND s.status = 'ACTIVE'
|
||||
ORDER BY s.username, s.osuser;
|
||||
|
||||
SET PAGESIZE 14
|
||||
|
||||
42
timhall/monitoring/active_user_sessions.sql
Normal file
42
timhall/monitoring/active_user_sessions.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/active_user_sessions.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all active database sessions.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @active_user_sessions
|
||||
-- Last Modified: 16-MAY-2019
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
|
||||
COLUMN username FORMAT A30
|
||||
COLUMN osuser FORMAT A20
|
||||
COLUMN spid FORMAT A10
|
||||
COLUMN service_name FORMAT A15
|
||||
COLUMN module FORMAT A45
|
||||
COLUMN machine FORMAT A30
|
||||
COLUMN logon_time FORMAT A20
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.osuser,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
p.spid,
|
||||
s.lockwait,
|
||||
s.status,
|
||||
s.machine,
|
||||
s.program,
|
||||
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,
|
||||
s.last_call_et AS last_call_et_secs,
|
||||
s.module,
|
||||
s.action,
|
||||
s.client_info,
|
||||
s.client_identifier
|
||||
FROM v$session s,
|
||||
v$process p
|
||||
WHERE s.paddr = p.addr
|
||||
AND s.status = 'ACTIVE'
|
||||
AND s.username IS NOT NULL
|
||||
ORDER BY s.username, s.osuser;
|
||||
|
||||
SET PAGESIZE 14
|
||||
22
timhall/monitoring/cache_hit_ratio.sql
Normal file
22
timhall/monitoring/cache_hit_ratio.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/cache_hit_ratio.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays cache hit ratio for the database.
|
||||
-- Comments : The minimum figure of 89% is often quoted, but depending on the type of system this may not be possible.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @cache_hit_ratio
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
PROMPT
|
||||
PROMPT Hit ratio should exceed 89%
|
||||
|
||||
SELECT Sum(Decode(a.name, 'consistent gets', a.value, 0)) "Consistent Gets",
|
||||
Sum(Decode(a.name, 'db block gets', a.value, 0)) "DB Block Gets",
|
||||
Sum(Decode(a.name, 'physical reads', a.value, 0)) "Physical Reads",
|
||||
Round(((Sum(Decode(a.name, 'consistent gets', a.value, 0)) +
|
||||
Sum(Decode(a.name, 'db block gets', a.value, 0)) -
|
||||
Sum(Decode(a.name, 'physical reads', a.value, 0)) )/
|
||||
(Sum(Decode(a.name, 'consistent gets', a.value, 0)) +
|
||||
Sum(Decode(a.name, 'db block gets', a.value, 0))))
|
||||
*100,2) "Hit Ratio %"
|
||||
FROM v$sysstat a;
|
||||
16
timhall/monitoring/call_stack.sql
Normal file
16
timhall/monitoring/call_stack.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/call_stack.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the current call stack.
|
||||
-- Requirements : Access to DBMS_UTILITY.
|
||||
-- Call Syntax : @call_stack
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
DECLARE
|
||||
v_stack VARCHAR2(2000);
|
||||
BEGIN
|
||||
v_stack := Dbms_Utility.Format_Call_Stack;
|
||||
Dbms_Output.Put_Line(v_stack);
|
||||
END;
|
||||
/
|
||||
28
timhall/monitoring/code_dep.sql
Normal file
28
timhall/monitoring/code_dep.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/code_dep.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays all dependencies of specified object.
|
||||
-- Call Syntax : @code_dep (schema-name or all) (object-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 255
|
||||
SET PAGESIZE 1000
|
||||
BREAK ON referenced_type SKIP 1
|
||||
|
||||
COLUMN referenced_type FORMAT A20
|
||||
COLUMN referenced_owner FORMAT A20
|
||||
COLUMN referenced_name FORMAT A40
|
||||
COLUMN referenced_link_name FORMAT A20
|
||||
|
||||
SELECT a.referenced_type,
|
||||
a.referenced_owner,
|
||||
a.referenced_name,
|
||||
a.referenced_link_name
|
||||
FROM all_dependencies a
|
||||
WHERE a.owner = DECODE(UPPER('&1'), 'ALL', a.referenced_owner, UPPER('&1'))
|
||||
AND a.name = UPPER('&2')
|
||||
ORDER BY 1,2,3;
|
||||
|
||||
SET VERIFY ON
|
||||
SET PAGESIZE 22
|
||||
31
timhall/monitoring/code_dep_distinct.sql
Normal file
31
timhall/monitoring/code_dep_distinct.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/code_dep_distinct.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a tree of dependencies of specified object.
|
||||
-- Call Syntax : @code_dep_distinct (schema-name) (object-name) (object_type or all)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 255
|
||||
SET PAGESIZE 1000
|
||||
|
||||
COLUMN referenced_object FORMAT A50
|
||||
COLUMN referenced_type FORMAT A20
|
||||
COLUMN referenced_link_name FORMAT A20
|
||||
|
||||
SELECT DISTINCT a.referenced_owner || '.' || a.referenced_name AS referenced_object,
|
||||
a.referenced_type,
|
||||
a.referenced_link_name
|
||||
FROM all_dependencies a
|
||||
WHERE a.owner NOT IN ('SYS','SYSTEM','PUBLIC')
|
||||
AND a.referenced_owner NOT IN ('SYS','SYSTEM','PUBLIC')
|
||||
AND a.referenced_type != 'NON-EXISTENT'
|
||||
AND a.referenced_type = DECODE(UPPER('&3'), 'ALL', a.referenced_type, UPPER('&3'))
|
||||
START WITH a.owner = UPPER('&1')
|
||||
AND a.name = UPPER('&2')
|
||||
CONNECT BY a.owner = PRIOR a.referenced_owner
|
||||
AND a.name = PRIOR a.referenced_name
|
||||
AND a.type = PRIOR a.referenced_type;
|
||||
|
||||
SET VERIFY ON
|
||||
SET PAGESIZE 22
|
||||
24
timhall/monitoring/code_dep_on.sql
Normal file
24
timhall/monitoring/code_dep_on.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/code_dep_on.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays all objects dependant on the specified object.
|
||||
-- Call Syntax : @code_dep_on (schema-name or all) (object-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 255
|
||||
SET PAGESIZE 1000
|
||||
BREAK ON type SKIP 1
|
||||
|
||||
COLUMN owner FORMAT A20
|
||||
|
||||
SELECT a.type,
|
||||
a.owner,
|
||||
a.name
|
||||
FROM all_dependencies a
|
||||
WHERE a.referenced_owner = DECODE(UPPER('&1'), 'ALL', a.referenced_owner, UPPER('&1'))
|
||||
AND a.referenced_name = UPPER('&2')
|
||||
ORDER BY 1,2,3;
|
||||
|
||||
SET PAGESIZE 22
|
||||
SET VERIFY ON
|
||||
30
timhall/monitoring/code_dep_tree.sql
Normal file
30
timhall/monitoring/code_dep_tree.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/code_dep_tree.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a tree of dependencies of specified object.
|
||||
-- Call Syntax : @code_dep_tree (schema-name) (object-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 255
|
||||
SET PAGESIZE 1000
|
||||
|
||||
COLUMN referenced_object FORMAT A50
|
||||
COLUMN referenced_type FORMAT A20
|
||||
COLUMN referenced_link_name FORMAT A20
|
||||
|
||||
SELECT RPAD(' ', level*2, ' ') || a.referenced_owner || '.' || a.referenced_name AS referenced_object,
|
||||
a.referenced_type,
|
||||
a.referenced_link_name
|
||||
FROM all_dependencies a
|
||||
WHERE a.owner NOT IN ('SYS','SYSTEM','PUBLIC')
|
||||
AND a.referenced_owner NOT IN ('SYS','SYSTEM','PUBLIC')
|
||||
AND a.referenced_type != 'NON-EXISTENT'
|
||||
START WITH a.owner = UPPER('&1')
|
||||
AND a.name = UPPER('&2')
|
||||
CONNECT BY a.owner = PRIOR a.referenced_owner
|
||||
AND a.name = PRIOR a.referenced_name
|
||||
AND a.type = PRIOR a.referenced_type;
|
||||
|
||||
SET VERIFY ON
|
||||
SET PAGESIZE 22
|
||||
16
timhall/monitoring/column_defaults.sql
Normal file
16
timhall/monitoring/column_defaults.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/column_defaults.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the default values where present for the specified table.
|
||||
-- Call Syntax : @column_defaults (table-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 100
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT a.column_name "Column",
|
||||
a.data_default "Default"
|
||||
FROM all_tab_columns a
|
||||
WHERE a.table_name = Upper('&1')
|
||||
AND a.data_default IS NOT NULL
|
||||
/
|
||||
18
timhall/monitoring/controlfiles.sql
Normal file
18
timhall/monitoring/controlfiles.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/controlfiles.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about controlfiles.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @controlfiles
|
||||
-- Last Modified: 21/12/2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET LINESIZE 100
|
||||
COLUMN name FORMAT A80
|
||||
|
||||
SELECT name,
|
||||
status
|
||||
FROM v$controlfile
|
||||
ORDER BY name;
|
||||
|
||||
SET LINESIZE 80
|
||||
21
timhall/monitoring/datafiles.sql
Normal file
21
timhall/monitoring/datafiles.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/datafiles.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about datafiles.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @datafiles
|
||||
-- Last Modified: 17-AUG-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET LINESIZE 200
|
||||
COLUMN file_name FORMAT A70
|
||||
|
||||
SELECT file_id,
|
||||
file_name,
|
||||
ROUND(bytes/1024/1024/1024) AS size_gb,
|
||||
ROUND(maxbytes/1024/1024/1024) AS max_size_gb,
|
||||
autoextensible,
|
||||
increment_by,
|
||||
status
|
||||
FROM dba_data_files
|
||||
ORDER BY file_name;
|
||||
24
timhall/monitoring/db_cache_advice.sql
Normal file
24
timhall/monitoring/db_cache_advice.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/db_cache_advice.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Predicts how changes to the buffer cache will affect physical reads.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @db_cache_advice
|
||||
-- Last Modified: 12/02/2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
COLUMN size_for_estimate FORMAT 999,999,999,999 heading 'Cache Size (MB)'
|
||||
COLUMN buffers_for_estimate FORMAT 999,999,999 heading 'Buffers'
|
||||
COLUMN estd_physical_read_factor FORMAT 999.90 heading 'Estd Phys|Read Factor'
|
||||
COLUMN estd_physical_reads FORMAT 999,999,999,999 heading 'Estd Phys| Reads'
|
||||
|
||||
SELECT size_for_estimate,
|
||||
buffers_for_estimate,
|
||||
estd_physical_read_factor,
|
||||
estd_physical_reads
|
||||
FROM v$db_cache_advice
|
||||
WHERE name = 'DEFAULT'
|
||||
AND block_size = (SELECT value
|
||||
FROM v$parameter
|
||||
WHERE name = 'db_block_size')
|
||||
AND advice_status = 'ON';
|
||||
48
timhall/monitoring/db_info.sql
Normal file
48
timhall/monitoring/db_info.sql
Normal file
@@ -0,0 +1,48 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/db_info.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays general information about the database.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @db_info
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET PAGESIZE 1000
|
||||
SET LINESIZE 100
|
||||
SET FEEDBACK OFF
|
||||
|
||||
SELECT *
|
||||
FROM v$database;
|
||||
|
||||
SELECT *
|
||||
FROM v$instance;
|
||||
|
||||
SELECT *
|
||||
FROM v$version;
|
||||
|
||||
SELECT a.name,
|
||||
a.value
|
||||
FROM v$sga a;
|
||||
|
||||
SELECT Substr(c.name,1,60) "Controlfile",
|
||||
NVL(c.status,'UNKNOWN') "Status"
|
||||
FROM v$controlfile c
|
||||
ORDER BY 1;
|
||||
|
||||
SELECT Substr(d.name,1,60) "Datafile",
|
||||
NVL(d.status,'UNKNOWN') "Status",
|
||||
d.enabled "Enabled",
|
||||
LPad(To_Char(Round(d.bytes/1024000,2),'9999990.00'),10,' ') "Size (M)"
|
||||
FROM v$datafile d
|
||||
ORDER BY 1;
|
||||
|
||||
SELECT l.group# "Group",
|
||||
Substr(l.member,1,60) "Logfile",
|
||||
NVL(l.status,'UNKNOWN') "Status"
|
||||
FROM v$logfile l
|
||||
ORDER BY 1,2;
|
||||
|
||||
PROMPT
|
||||
SET PAGESIZE 14
|
||||
SET FEEDBACK ON
|
||||
|
||||
|
||||
21
timhall/monitoring/db_links.sql
Normal file
21
timhall/monitoring/db_links.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/db_links.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all database links.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @db_links
|
||||
-- Last Modified: 11/05/2007
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 150
|
||||
|
||||
COLUMN owner FORMAT A30
|
||||
COLUMN db_link FORMAT A30
|
||||
COLUMN username FORMAT A30
|
||||
COLUMN host FORMAT A30
|
||||
|
||||
SELECT owner,
|
||||
db_link,
|
||||
username,
|
||||
host
|
||||
FROM dba_db_links
|
||||
ORDER BY owner, db_link;
|
||||
25
timhall/monitoring/db_links_open.sql
Normal file
25
timhall/monitoring/db_links_open.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/db_links_open.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all open database links.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @db_links_open
|
||||
-- Last Modified: 11/05/2007
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
COLUMN db_link FORMAT A30
|
||||
|
||||
SELECT db_link,
|
||||
owner_id,
|
||||
logged_on,
|
||||
heterogeneous,
|
||||
protocol,
|
||||
open_cursors,
|
||||
in_transaction,
|
||||
update_sent,
|
||||
commit_point_strength
|
||||
FROM v$dblink
|
||||
ORDER BY db_link;
|
||||
|
||||
SET LINESIZE 80
|
||||
13
timhall/monitoring/db_properties.sql
Normal file
13
timhall/monitoring/db_properties.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/db_properties.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays all database property values.
|
||||
-- Call Syntax : @db_properties
|
||||
-- Last Modified: 15/09/2006
|
||||
-- -----------------------------------------------------------------------------------
|
||||
COLUMN property_value FORMAT A50
|
||||
|
||||
SELECT property_name,
|
||||
property_value
|
||||
FROM database_properties
|
||||
ORDER BY property_name;
|
||||
16
timhall/monitoring/default_tablespaces.sql
Normal file
16
timhall/monitoring/default_tablespaces.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/default_tablespaces.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the default temporary and permanent tablespaces.
|
||||
-- Requirements : Access to the DATABASE_PROPERTIES views.
|
||||
-- Call Syntax : @default_tablespaces
|
||||
-- Last Modified: 04/06/2019
|
||||
-- -----------------------------------------------------------------------------------
|
||||
COLUMN property_name FORMAT A30
|
||||
COLUMN property_value FORMAT A30
|
||||
COLUMN description FORMAT A50
|
||||
SET LINESIZE 200
|
||||
|
||||
SELECT *
|
||||
FROM database_properties
|
||||
WHERE property_name like '%TABLESPACE';
|
||||
30
timhall/monitoring/df_free_space.sql
Normal file
30
timhall/monitoring/df_free_space.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/df_free_space.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays free space information about datafiles.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @df_free_space.sql
|
||||
-- Last Modified: 17-AUG-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET LINESIZE 120
|
||||
COLUMN file_name FORMAT A60
|
||||
|
||||
SELECT a.file_name,
|
||||
ROUND(a.bytes/1024/1024) AS size_mb,
|
||||
ROUND(a.maxbytes/1024/1024) AS maxsize_mb,
|
||||
ROUND(b.free_bytes/1024/1024) AS free_mb,
|
||||
ROUND((a.maxbytes-a.bytes)/1024/1024) AS growth_mb,
|
||||
100 - ROUND(((b.free_bytes+a.growth)/a.maxbytes) * 100) AS pct_used
|
||||
FROM (SELECT file_name,
|
||||
file_id,
|
||||
bytes,
|
||||
GREATEST(bytes,maxbytes) AS maxbytes,
|
||||
GREATEST(bytes,maxbytes)-bytes AS growth
|
||||
FROM dba_data_files) a,
|
||||
(SELeCT file_id,
|
||||
SUM(bytes) AS free_bytes
|
||||
FROM dba_free_space
|
||||
GROUP BY file_id) b
|
||||
WHERE a.file_id = b.file_id
|
||||
ORDER BY file_name;
|
||||
17
timhall/monitoring/directories.sql
Normal file
17
timhall/monitoring/directories.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/directories.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all directories.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @directories
|
||||
-- Last Modified: 04/10/2006
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 150
|
||||
|
||||
COLUMN owner FORMAT A20
|
||||
COLUMN directory_name FORMAT A25
|
||||
COLUMN directory_path FORMAT A80
|
||||
|
||||
SELECT *
|
||||
FROM dba_directories
|
||||
ORDER BY owner, directory_name;
|
||||
19
timhall/monitoring/directory_permissions.sql
Normal file
19
timhall/monitoring/directory_permissions.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/directory_permissions.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays permission information about all directories.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @directory_permissions (directory_name)
|
||||
-- Last Modified: 09/02/2016
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
COLUMN grantee FORMAT A20
|
||||
COLUMN owner FORMAT A10
|
||||
COLUMN grantor FORMAT A20
|
||||
COLUMN privilege FORMAT A20
|
||||
|
||||
COLUMN
|
||||
SELECT *
|
||||
FROM dba_tab_privs
|
||||
WHERE table_name = UPPER('&1');
|
||||
26
timhall/monitoring/dispatchers.sql
Normal file
26
timhall/monitoring/dispatchers.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/dispatchers.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays dispatcher statistics.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @dispatchers
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT a.name "Name",
|
||||
a.status "Status",
|
||||
a.accept "Accept",
|
||||
a.messages "Total Mesgs",
|
||||
a.bytes "Total Bytes",
|
||||
a.owned "Circs Owned",
|
||||
a.idle "Total Idle Time",
|
||||
a.busy "Total Busy Time",
|
||||
Round(a.busy/(a.busy + a.idle),2) "Load"
|
||||
FROM v$dispatcher a
|
||||
ORDER BY 1;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
15
timhall/monitoring/error_stack.sql
Normal file
15
timhall/monitoring/error_stack.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/error_stack.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays contents of the error stack.
|
||||
-- Call Syntax : @error_stack
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
DECLARE
|
||||
v_stack VARCHAR2(2000);
|
||||
BEGIN
|
||||
v_stack := Dbms_Utility.Format_Error_Stack;
|
||||
Dbms_Output.Put_Line(v_stack);
|
||||
END;
|
||||
/
|
||||
16
timhall/monitoring/errors.sql
Normal file
16
timhall/monitoring/errors.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/errors.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the source line and the associated error after compilation failure.
|
||||
-- Comments : Essentially the same as SHOW ERRORS.
|
||||
-- Call Syntax : @errors (source-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SELECT To_Char(a.line) || ' - ' || a.text error
|
||||
FROM user_source a,
|
||||
user_errors b
|
||||
WHERE a.name = Upper('&&1')
|
||||
AND a.name = b.name
|
||||
AND a.type = b.type
|
||||
AND a.line = b.line
|
||||
ORDER BY a.name, a.line;
|
||||
35
timhall/monitoring/explain.sql
Normal file
35
timhall/monitoring/explain.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/explain.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a tree-style execution plan of the specified statement after it has been explained.
|
||||
-- Requirements : Access to the plan table.
|
||||
-- Call Syntax : @explain (statement-id)
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET PAGESIZE 100
|
||||
SET LINESIZE 200
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN plan FORMAT A50
|
||||
COLUMN object_name FORMAT A30
|
||||
COLUMN object_type FORMAT A15
|
||||
COLUMN bytes FORMAT 9999999999
|
||||
COLUMN cost FORMAT 9999999
|
||||
COLUMN partition_start FORMAT A20
|
||||
COLUMN partition_stop FORMAT A20
|
||||
|
||||
SELECT LPAD(' ', 2 * (level - 1)) ||
|
||||
DECODE (level,1,NULL,level-1 || '.' || pt.position || ' ') ||
|
||||
INITCAP(pt.operation) ||
|
||||
DECODE(pt.options,NULL,'',' (' || INITCAP(pt.options) || ')') plan,
|
||||
pt.object_name,
|
||||
pt.object_type,
|
||||
pt.bytes,
|
||||
pt.cost,
|
||||
pt.partition_start,
|
||||
pt.partition_stop
|
||||
FROM plan_table pt
|
||||
START WITH pt.id = 0
|
||||
AND pt.statement_id = '&1'
|
||||
CONNECT BY PRIOR pt.id = pt.parent_id
|
||||
AND pt.statement_id = '&1';
|
||||
20
timhall/monitoring/file_io.sql
Normal file
20
timhall/monitoring/file_io.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/file_io.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the amount of IO for each datafile.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @file_io
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET PAGESIZE 1000
|
||||
|
||||
SELECT Substr(d.name,1,50) "File Name",
|
||||
f.phyblkrd "Blocks Read",
|
||||
f.phyblkwrt "Blocks Writen",
|
||||
f.phyblkrd + f.phyblkwrt "Total I/O"
|
||||
FROM v$filestat f,
|
||||
v$datafile d
|
||||
WHERE d.file# = f.file#
|
||||
ORDER BY f.phyblkrd + f.phyblkwrt DESC;
|
||||
|
||||
SET PAGESIZE 18
|
||||
25
timhall/monitoring/fk_columns.sql
Normal file
25
timhall/monitoring/fk_columns.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : http://www.oracle-base.com/dba/monitoring/fk_columns.sql
|
||||
-- Author : DR Timothy S Hall
|
||||
-- Description : Displays information on all FKs for the specified schema and table.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @fk_columns (schema-name or all) (table-name or all)
|
||||
-- Last Modified: 22/09/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 1000
|
||||
COLUMN column_name FORMAT A30
|
||||
COLUMN r_column_name FORMAT A30
|
||||
|
||||
SELECT c.constraint_name,
|
||||
cc.table_name,
|
||||
cc.column_name,
|
||||
rcc.table_name AS r_table_name,
|
||||
rcc.column_name AS r_column_name,
|
||||
cc.position
|
||||
FROM dba_constraints c
|
||||
JOIN dba_cons_columns cc ON c.owner = cc.owner AND c.constraint_name = cc.constraint_name
|
||||
JOIN dba_cons_columns rcc ON c.owner = rcc.owner AND c.r_constraint_name = rcc.constraint_name AND cc.position = rcc.position
|
||||
WHERE c.owner = DECODE(UPPER('&1'), 'ALL', c.owner, UPPER('&1'))
|
||||
AND c.table_name = DECODE(UPPER('&2'), 'ALL', c.table_name, UPPER('&2'))
|
||||
ORDER BY c.constraint_name, cc.table_name, cc.position;
|
||||
47
timhall/monitoring/fks.sql
Normal file
47
timhall/monitoring/fks.sql
Normal file
@@ -0,0 +1,47 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/fks.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the constraints on a specific table and those referencing it.
|
||||
-- Call Syntax : @fks (table-name) (schema)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
PROMPT
|
||||
SET VERIFY OFF
|
||||
SET FEEDBACK OFF
|
||||
SET LINESIZE 255
|
||||
SET PAGESIZE 1000
|
||||
|
||||
PROMPT
|
||||
PROMPT Constraints Owned By Table
|
||||
PROMPT ==========================
|
||||
SELECT c.constraint_name "Constraint",
|
||||
Decode(c.constraint_type,'P','Primary Key',
|
||||
'U','Unique Key',
|
||||
'C','Check',
|
||||
'R','Foreign Key',
|
||||
c.constraint_type) "Type",
|
||||
c.r_owner "Ref Table",
|
||||
c.r_constraint_name "Ref Constraint"
|
||||
FROM all_constraints c
|
||||
WHERE c.table_name = Upper('&&1')
|
||||
AND c.owner = Upper('&&2');
|
||||
|
||||
|
||||
PROMPT
|
||||
PROMPT Constraints Referencing Table
|
||||
PROMPT =============================
|
||||
SELECT c1.table_name "Table",
|
||||
c1.constraint_name "Foreign Key",
|
||||
c1.r_constraint_name "References"
|
||||
FROM all_constraints c1
|
||||
WHERE c1.owner = Upper('&&2')
|
||||
AND c1.r_constraint_name IN (SELECT c2.constraint_name
|
||||
FROM all_constraints c2
|
||||
WHERE c2.table_name = Upper('&&1')
|
||||
AND c2.owner = Upper('&&2')
|
||||
AND c2.constraint_type IN ('P','U'));
|
||||
|
||||
SET VERIFY ON
|
||||
SET FEEDBACK ON
|
||||
SET PAGESIZE 1000
|
||||
PROMPT
|
||||
38
timhall/monitoring/free_space.sql
Normal file
38
timhall/monitoring/free_space.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/free_space.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays space usage for each datafile.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @free_space
|
||||
-- Last Modified: 15-JUL-2000 - Created.
|
||||
-- 12-OCT-2012 - Amended to include auto-extend and maxsize.
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET PAGESIZE 100
|
||||
SET LINESIZE 265
|
||||
|
||||
COLUMN tablespace_name FORMAT A20
|
||||
COLUMN file_name FORMAT A50
|
||||
|
||||
SELECT df.tablespace_name,
|
||||
df.file_name,
|
||||
df.size_mb,
|
||||
f.free_mb,
|
||||
df.max_size_mb,
|
||||
f.free_mb + (df.max_size_mb - df.size_mb) AS max_free_mb,
|
||||
RPAD(' '|| RPAD('X',ROUND((df.max_size_mb-(f.free_mb + (df.max_size_mb - df.size_mb)))/max_size_mb*10,0), 'X'),11,'-') AS used_pct
|
||||
FROM (SELECT file_id,
|
||||
file_name,
|
||||
tablespace_name,
|
||||
TRUNC(bytes/1024/1024) AS size_mb,
|
||||
TRUNC(GREATEST(bytes,maxbytes)/1024/1024) AS max_size_mb
|
||||
FROM dba_data_files) df,
|
||||
(SELECT TRUNC(SUM(bytes)/1024/1024) AS free_mb,
|
||||
file_id
|
||||
FROM dba_free_space
|
||||
GROUP BY file_id) f
|
||||
WHERE df.file_id = f.file_id (+)
|
||||
ORDER BY df.tablespace_name,
|
||||
df.file_name;
|
||||
|
||||
PROMPT
|
||||
SET PAGESIZE 14
|
||||
17
timhall/monitoring/health.sql
Normal file
17
timhall/monitoring/health.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/health.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lots of information about the database so you can asses the general health of the system.
|
||||
-- Requirements : Access to the V$ & DBA views and several other monitoring scripts.
|
||||
-- Call Syntax : @health (username/password@service)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SPOOL Health_Checks.txt
|
||||
|
||||
conn &1
|
||||
@db_info
|
||||
@sessions
|
||||
@ts_full
|
||||
@max_extents
|
||||
|
||||
SPOOL OFF
|
||||
26
timhall/monitoring/hidden_parameters.sql
Normal file
26
timhall/monitoring/hidden_parameters.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : http://www.oracle-base.com/dba/monitoring/hidden_parameters.sql
|
||||
-- Author : DR Timothy S Hall
|
||||
-- Description : Displays a list of one or all the hidden parameters.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @hidden_parameters (parameter-name or all)
|
||||
-- Last Modified: 28-NOV-2006
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
COLUMN parameter FORMAT a37
|
||||
COLUMN description FORMAT a30 WORD_WRAPPED
|
||||
COLUMN session_value FORMAT a10
|
||||
COLUMN instance_value FORMAT a10
|
||||
|
||||
SELECT a.ksppinm AS parameter,
|
||||
a.ksppdesc AS description,
|
||||
b.ksppstvl AS session_value,
|
||||
c.ksppstvl AS instance_value
|
||||
FROM x$ksppi a,
|
||||
x$ksppcv b,
|
||||
x$ksppsv c
|
||||
WHERE a.indx = b.indx
|
||||
AND a.indx = c.indx
|
||||
AND a.ksppinm LIKE '/_%' ESCAPE '/'
|
||||
AND a.ksppinm = DECODE(LOWER('&1'), 'all', a.ksppinm, LOWER('&1'))
|
||||
ORDER BY a.ksppinm;
|
||||
44
timhall/monitoring/high_water_mark.sql
Normal file
44
timhall/monitoring/high_water_mark.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/high_water_mark.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the High Water Mark for the specified table, or all tables.
|
||||
-- Requirements : Access to the Dbms_Space.
|
||||
-- Call Syntax : @high_water_mark (table_name or all) (schema-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
SET VERIFY OFF
|
||||
|
||||
DECLARE
|
||||
CURSOR cu_tables IS
|
||||
SELECT a.owner,
|
||||
a.table_name
|
||||
FROM all_tables a
|
||||
WHERE a.table_name = Decode(Upper('&&1'),'ALL',a.table_name,Upper('&&1'))
|
||||
AND a.owner = Upper('&&2');
|
||||
|
||||
op1 NUMBER;
|
||||
op2 NUMBER;
|
||||
op3 NUMBER;
|
||||
op4 NUMBER;
|
||||
op5 NUMBER;
|
||||
op6 NUMBER;
|
||||
op7 NUMBER;
|
||||
BEGIN
|
||||
|
||||
Dbms_Output.Disable;
|
||||
Dbms_Output.Enable(1000000);
|
||||
Dbms_Output.Put_Line('TABLE UNUSED BLOCKS TOTAL BLOCKS HIGH WATER MARK');
|
||||
Dbms_Output.Put_Line('------------------------------ --------------- --------------- ---------------');
|
||||
FOR cur_rec IN cu_tables LOOP
|
||||
Dbms_Space.Unused_Space(cur_rec.owner,cur_rec.table_name,'TABLE',op1,op2,op3,op4,op5,op6,op7);
|
||||
Dbms_Output.Put_Line(RPad(cur_rec.table_name,30,' ') ||
|
||||
LPad(op3,15,' ') ||
|
||||
LPad(op1,15,' ') ||
|
||||
LPad(Trunc(op1-op3-1),15,' '));
|
||||
END LOOP;
|
||||
|
||||
END;
|
||||
/
|
||||
|
||||
SET VERIFY ON
|
||||
44
timhall/monitoring/hot_blocks.sql
Normal file
44
timhall/monitoring/hot_blocks.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/hot_blocks.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Detects hot blocks.
|
||||
-- Call Syntax : @hot_blocks
|
||||
-- Last Modified: 17/02/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT *
|
||||
FROM (SELECT name,
|
||||
addr,
|
||||
gets,
|
||||
misses,
|
||||
sleeps
|
||||
FROM v$latch_children
|
||||
WHERE name = 'cache buffers chains'
|
||||
AND misses > 0
|
||||
ORDER BY misses DESC)
|
||||
WHERE rownum < 11;
|
||||
|
||||
ACCEPT address PROMPT "Enter ADDR: "
|
||||
|
||||
COLUMN owner FORMAT A15
|
||||
COLUMN object_name FORMAT A30
|
||||
COLUMN subobject_name FORMAT A20
|
||||
|
||||
SELECT *
|
||||
FROM (SELECT o.owner,
|
||||
o.object_name,
|
||||
o.subobject_name,
|
||||
bh.tch,
|
||||
bh.obj,
|
||||
bh.file#,
|
||||
bh.dbablk,
|
||||
bh.class,
|
||||
bh.state
|
||||
FROM x$bh bh,
|
||||
dba_objects o
|
||||
WHERE o.data_object_id = bh.obj
|
||||
AND hladdr = '&address'
|
||||
ORDER BY tch DESC)
|
||||
WHERE rownum < 11;
|
||||
21
timhall/monitoring/identify_trace_file.sql
Normal file
21
timhall/monitoring/identify_trace_file.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/identify_trace_file.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the name of the trace file associated with the current session.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @identify_trace_file
|
||||
-- Last Modified: 17-AUG-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 100
|
||||
COLUMN trace_file FORMAT A60
|
||||
|
||||
SELECT s.sid,
|
||||
s.serial#,
|
||||
pa.value || '/' || LOWER(SYS_CONTEXT('userenv','instance_name')) ||
|
||||
'_ora_' || p.spid || '.trc' AS trace_file
|
||||
FROM v$session s,
|
||||
v$process p,
|
||||
v$parameter pa
|
||||
WHERE pa.name = 'user_dump_dest'
|
||||
AND s.paddr = p.addr
|
||||
AND s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');
|
||||
39
timhall/monitoring/index_extents.sql
Normal file
39
timhall/monitoring/index_extents.sql
Normal file
@@ -0,0 +1,39 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/index_extents.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays number of extents for all indexes belonging to the specified table, or all tables.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @index_extents (table_name or all) (schema-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT i.index_name,
|
||||
Count(e.segment_name) extents,
|
||||
i.max_extents,
|
||||
t.num_rows "ROWS",
|
||||
Trunc(i.initial_extent/1024) "INITIAL K",
|
||||
Trunc(i.next_extent/1024) "NEXT K",
|
||||
t.table_name
|
||||
FROM all_tables t,
|
||||
all_indexes i,
|
||||
dba_extents e
|
||||
WHERE i.table_name = t.table_name
|
||||
AND i.owner = t.owner
|
||||
AND e.segment_name = i.index_name
|
||||
AND e.owner = i.owner
|
||||
AND i.table_name = Decode(Upper('&&1'),'ALL',i.table_name,Upper('&&1'))
|
||||
AND i.owner = Upper('&&2')
|
||||
GROUP BY t.table_name,
|
||||
i.index_name,
|
||||
i.max_extents,
|
||||
t.num_rows,
|
||||
i.initial_extent,
|
||||
i.next_extent
|
||||
HAVING Count(e.segment_name) > 5
|
||||
ORDER BY Count(e.segment_name) DESC;
|
||||
|
||||
SET PAGESIZE 18
|
||||
SET VERIFY ON
|
||||
15
timhall/monitoring/index_monitoring_status.sql
Normal file
15
timhall/monitoring/index_monitoring_status.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/index_monitoring_status.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Shows the monitoring status for the specified table indexes.
|
||||
-- Call Syntax : @index_monitoring_status (table-name) (index-name or all)
|
||||
-- Last Modified: 04/02/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT table_name,
|
||||
index_name,
|
||||
monitoring
|
||||
FROM v$object_usage
|
||||
WHERE table_name = UPPER('&1')
|
||||
AND index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2'));
|
||||
29
timhall/monitoring/index_partitions.sql
Normal file
29
timhall/monitoring/index_partitions.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/index_partitions.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays partition information for the specified index, or all indexes.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @index_patitions (index_name or all) (schema-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET FEEDBACK OFF
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT a.index_name,
|
||||
a.partition_name,
|
||||
a.tablespace_name,
|
||||
a.initial_extent,
|
||||
a.next_extent,
|
||||
a.pct_increase,
|
||||
a.num_rows
|
||||
FROM dba_ind_partitions a
|
||||
WHERE a.index_name = Decode(Upper('&&1'),'ALL',a.index_name,Upper('&&1'))
|
||||
AND a.index_owner = Upper('&&2')
|
||||
ORDER BY a.index_name, a.partition_name
|
||||
/
|
||||
|
||||
PROMPT
|
||||
SET PAGESIZE 14
|
||||
SET FEEDBACK ON
|
||||
18
timhall/monitoring/index_usage.sql
Normal file
18
timhall/monitoring/index_usage.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/index_usage.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Shows the usage for the specified table indexes.
|
||||
-- Call Syntax : @index_usage (table-name) (index-name or all)
|
||||
-- Last Modified: 04/02/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 200
|
||||
|
||||
SELECT table_name,
|
||||
index_name,
|
||||
used,
|
||||
start_monitoring,
|
||||
end_monitoring
|
||||
FROM v$object_usage
|
||||
WHERE table_name = UPPER('&1')
|
||||
AND index_name = DECODE(UPPER('&2'), 'ALL', index_name, UPPER('&2'));
|
||||
18
timhall/monitoring/invalid_objects.sql
Normal file
18
timhall/monitoring/invalid_objects.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/invalid_objects.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists all invalid objects in the database.
|
||||
-- Call Syntax : @invalid_objects
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Last Modified: 18/12/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
COLUMN owner FORMAT A30
|
||||
COLUMN object_name FORMAT A30
|
||||
|
||||
SELECT owner,
|
||||
object_type,
|
||||
object_name,
|
||||
status
|
||||
FROM dba_objects
|
||||
WHERE status = 'INVALID'
|
||||
ORDER BY owner, object_type, object_name;
|
||||
35
timhall/monitoring/jobs.sql
Normal file
35
timhall/monitoring/jobs.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/jobs.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all scheduled jobs.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @jobs
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 1000 PAGESIZE 1000
|
||||
|
||||
COLUMN log_user FORMAT A15
|
||||
COLUMN priv_user FORMAT A15
|
||||
COLUMN schema_user FORMAT A15
|
||||
COLUMN interval FORMAT A40
|
||||
COLUMN what FORMAT A50
|
||||
COLUMN nls_env FORMAT A50
|
||||
COLUMN misc_env FORMAT A50
|
||||
|
||||
SELECT a.job,
|
||||
a.log_user,
|
||||
a.priv_user,
|
||||
a.schema_user,
|
||||
To_Char(a.last_date,'DD-MON-YYYY HH24:MI:SS') AS last_date,
|
||||
--To_Char(a.this_date,'DD-MON-YYYY HH24:MI:SS') AS this_date,
|
||||
To_Char(a.next_date,'DD-MON-YYYY HH24:MI:SS') AS next_date,
|
||||
a.broken,
|
||||
a.interval,
|
||||
a.failures,
|
||||
a.what,
|
||||
a.total_time,
|
||||
a.nls_env,
|
||||
a.misc_env
|
||||
FROM dba_jobs a;
|
||||
|
||||
SET LINESIZE 80 PAGESIZE 14
|
||||
21
timhall/monitoring/jobs_running.sql
Normal file
21
timhall/monitoring/jobs_running.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/jobs_running.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all jobs currently running.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @jobs_running
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT a.job "Job",
|
||||
a.sid,
|
||||
a.failures "Failures",
|
||||
Substr(To_Char(a.last_date,'DD-Mon-YYYY HH24:MI:SS'),1,20) "Last Date",
|
||||
Substr(To_Char(a.this_date,'DD-Mon-YYYY HH24:MI:SS'),1,20) "This Date"
|
||||
FROM dba_jobs_running a;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
29
timhall/monitoring/large_lob_segments.sql
Normal file
29
timhall/monitoring/large_lob_segments.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/large_lob_segments.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays size of large LOB segments.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @large_lob_segments (rows)
|
||||
-- Last Modified: 12/09/2017
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500 VERIFY OFF
|
||||
COLUMN owner FORMAT A30
|
||||
COLUMN table_name FORMAT A30
|
||||
COLUMN column_name FORMAT A30
|
||||
COLUMN segment_name FORMAT A30
|
||||
COLUMN tablespace_name FORMAT A30
|
||||
COLUMN size_mb FORMAT 99999999.00
|
||||
|
||||
SELECT *
|
||||
FROM (SELECT l.owner,
|
||||
l.table_name,
|
||||
l.column_name,
|
||||
l.segment_name,
|
||||
l.tablespace_name,
|
||||
ROUND(s.bytes/1024/1024,2) size_mb
|
||||
FROM dba_lobs l
|
||||
JOIN dba_segments s ON s.owner = l.owner AND s.segment_name = l.segment_name
|
||||
ORDER BY 6 DESC)
|
||||
WHERE ROWNUM <= &1;
|
||||
|
||||
SET VERIFY ON
|
||||
25
timhall/monitoring/large_segments.sql
Normal file
25
timhall/monitoring/large_segments.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/large_segments.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays size of large segments.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @large_segments (rows)
|
||||
-- Last Modified: 12/09/2017
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500 VERIFY OFF
|
||||
COLUMN owner FORMAT A30
|
||||
COLUMN segment_name FORMAT A30
|
||||
COLUMN tablespace_name FORMAT A30
|
||||
COLUMN size_mb FORMAT 99999999.00
|
||||
|
||||
SELECT *
|
||||
FROM (SELECT owner,
|
||||
segment_name,
|
||||
segment_type,
|
||||
tablespace_name,
|
||||
ROUND(bytes/1024/1024,2) size_mb
|
||||
FROM dba_segments
|
||||
ORDER BY 5 DESC)
|
||||
WHERE ROWNUM <= &1;
|
||||
|
||||
SET VERIFY ON
|
||||
26
timhall/monitoring/latch_hit_ratios.sql
Normal file
26
timhall/monitoring/latch_hit_ratios.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/latch_hit_ratios.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays current latch hit ratios.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @latch_hit_ratios
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
COLUMN latch_hit_ratio FORMAT 990.00
|
||||
|
||||
SELECT l.name,
|
||||
l.gets,
|
||||
l.misses,
|
||||
((1 - (l.misses / l.gets)) * 100) AS latch_hit_ratio
|
||||
FROM v$latch l
|
||||
WHERE l.gets != 0
|
||||
UNION
|
||||
SELECT l.name,
|
||||
l.gets,
|
||||
l.misses,
|
||||
100 AS latch_hit_ratio
|
||||
FROM v$latch l
|
||||
WHERE l.gets = 0
|
||||
ORDER BY 4 DESC;
|
||||
22
timhall/monitoring/latch_holders.sql
Normal file
22
timhall/monitoring/latch_holders.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/latch_holders.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all current latch holders.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @latch_holders
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
SELECT l.name "Latch Name",
|
||||
lh.pid "PID",
|
||||
lh.sid "SID",
|
||||
l.gets "Gets (Wait)",
|
||||
l.misses "Misses (Wait)",
|
||||
l.sleeps "Sleeps (Wait)",
|
||||
l.immediate_gets "Gets (No Wait)",
|
||||
l.immediate_misses "Misses (Wait)"
|
||||
FROM v$latch l,
|
||||
v$latchholder lh
|
||||
WHERE l.addr = lh.laddr
|
||||
ORDER BY l.name;
|
||||
20
timhall/monitoring/latches.sql
Normal file
20
timhall/monitoring/latches.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/latches.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all current latches.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @latches
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
SELECT l.latch#,
|
||||
l.name,
|
||||
l.gets,
|
||||
l.misses,
|
||||
l.sleeps,
|
||||
l.immediate_gets,
|
||||
l.immediate_misses,
|
||||
l.spin_gets
|
||||
FROM v$latch l
|
||||
ORDER BY l.name;
|
||||
26
timhall/monitoring/library_cache.sql
Normal file
26
timhall/monitoring/library_cache.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/library_cache.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays library cache statistics.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @library_cache
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT a.namespace "Name Space",
|
||||
a.gets "Get Requests",
|
||||
a.gethits "Get Hits",
|
||||
Round(a.gethitratio,2) "Get Ratio",
|
||||
a.pins "Pin Requests",
|
||||
a.pinhits "Pin Hits",
|
||||
Round(a.pinhitratio,2) "Pin Ratio",
|
||||
a.reloads "Reloads",
|
||||
a.invalidations "Invalidations"
|
||||
FROM v$librarycache a
|
||||
ORDER BY 1;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
10
timhall/monitoring/license.sql
Normal file
10
timhall/monitoring/license.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/license.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays session usage for licensing purposes.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @license
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SELECT *
|
||||
FROM v$license;
|
||||
39
timhall/monitoring/locked_objects.sql
Normal file
39
timhall/monitoring/locked_objects.sql
Normal file
@@ -0,0 +1,39 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/locked_objects.sql
|
||||
-- Author : DR Timothy S Hall
|
||||
-- Description : Lists all locked objects.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @locked_objects
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN owner FORMAT A20
|
||||
COLUMN username FORMAT A20
|
||||
COLUMN object_owner FORMAT A20
|
||||
COLUMN object_name FORMAT A30
|
||||
COLUMN locked_mode FORMAT A15
|
||||
|
||||
SELECT lo.session_id AS sid,
|
||||
s.serial#,
|
||||
NVL(lo.oracle_username, '(oracle)') AS username,
|
||||
o.owner AS object_owner,
|
||||
o.object_name,
|
||||
Decode(lo.locked_mode, 0, 'None',
|
||||
1, 'Null (NULL)',
|
||||
2, 'Row-S (SS)',
|
||||
3, 'Row-X (SX)',
|
||||
4, 'Share (S)',
|
||||
5, 'S/Row-X (SSX)',
|
||||
6, 'Exclusive (X)',
|
||||
lo.locked_mode) locked_mode,
|
||||
lo.os_user_name
|
||||
FROM v$locked_object lo
|
||||
JOIN dba_objects o ON o.object_id = lo.object_id
|
||||
JOIN v$session s ON lo.session_id = s.sid
|
||||
ORDER BY 1, 2, 3, 4;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
28
timhall/monitoring/locked_objects_internal.sql
Normal file
28
timhall/monitoring/locked_objects_internal.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : http://www.oracle-base.com/dba/monitoring/locked_objects_internal.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists all locks on the specific object.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @locked_objects_internal (object-name)
|
||||
-- Last Modified: 16/02/2018
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 1000 VERIFY OFF
|
||||
|
||||
COLUMN lock_type FORMAT A20
|
||||
COLUMN mode_held FORMAT A10
|
||||
COLUMN mode_requested FORMAT A10
|
||||
COLUMN lock_id1 FORMAT A50
|
||||
COLUMN lock_id2 FORMAT A30
|
||||
|
||||
SELECT li.session_id AS sid,
|
||||
s.serial#,
|
||||
li.lock_type,
|
||||
li.mode_held,
|
||||
li.mode_requested,
|
||||
li.lock_id1,
|
||||
li.lock_id2
|
||||
FROM dba_lock_internal li
|
||||
JOIN v$session s ON li.session_id = s.sid
|
||||
WHERE UPPER(lock_id1) LIKE UPPER('%&1%');
|
||||
|
||||
SET VERIFY ON
|
||||
30
timhall/monitoring/logfiles.sql
Normal file
30
timhall/monitoring/logfiles.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/logfiles.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about redo log files.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @logfiles
|
||||
-- Last Modified: 21/12/2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET LINESIZE 200
|
||||
COLUMN member FORMAT A50
|
||||
COLUMN first_change# FORMAT 99999999999999999999
|
||||
COLUMN next_change# FORMAT 99999999999999999999
|
||||
|
||||
SELECT l.thread#,
|
||||
lf.group#,
|
||||
lf.member,
|
||||
TRUNC(l.bytes/1024/1024) AS size_mb,
|
||||
l.status,
|
||||
l.archived,
|
||||
lf.type,
|
||||
lf.is_recovery_dest_file AS rdf,
|
||||
l.sequence#,
|
||||
l.first_change#,
|
||||
l.next_change#
|
||||
FROM v$logfile lf
|
||||
JOIN v$log l ON l.group# = lf.group#
|
||||
ORDER BY l.thread#,lf.group#, lf.member;
|
||||
|
||||
SET LINESIZE 80
|
||||
26
timhall/monitoring/longops.sql
Normal file
26
timhall/monitoring/longops.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/longops.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all long operations.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @longops
|
||||
-- Last Modified: 03/07/2003
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
COLUMN sid FORMAT 999
|
||||
COLUMN serial# FORMAT 9999999
|
||||
COLUMN machine FORMAT A30
|
||||
COLUMN progress_pct FORMAT 99999999.00
|
||||
COLUMN elapsed FORMAT A10
|
||||
COLUMN remaining FORMAT A10
|
||||
|
||||
SELECT s.sid,
|
||||
s.serial#,
|
||||
s.machine,
|
||||
ROUND(sl.elapsed_seconds/60) || ':' || MOD(sl.elapsed_seconds,60) elapsed,
|
||||
ROUND(sl.time_remaining/60) || ':' || MOD(sl.time_remaining,60) remaining,
|
||||
ROUND(sl.sofar/sl.totalwork*100, 2) progress_pct
|
||||
FROM v$session s,
|
||||
v$session_longops sl
|
||||
WHERE s.sid = sl.sid
|
||||
AND s.serial# = sl.serial#;
|
||||
23
timhall/monitoring/lru_latch_ratio.sql
Normal file
23
timhall/monitoring/lru_latch_ratio.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/lru_latch_ratio.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays current LRU latch ratios.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @lru_latch_hit_ratio
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
COLUMN "Ratio %" FORMAT 990.00
|
||||
|
||||
PROMPT
|
||||
PROMPT Values greater than 3% indicate contention.
|
||||
|
||||
SELECT a.child#,
|
||||
(a.SLEEPS / a.GETS) * 100 "Ratio %"
|
||||
FROM v$latch_children a
|
||||
WHERE a.name = 'cache buffers lru chain'
|
||||
ORDER BY 1;
|
||||
|
||||
|
||||
SET PAGESIZE 14
|
||||
30
timhall/monitoring/max_extents.sql
Normal file
30
timhall/monitoring/max_extents.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/max_extents.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays all tables and indexes nearing their MAX_EXTENTS setting.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @max_extents
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
PROMPT
|
||||
PROMPT Tables and Indexes nearing MAX_EXTENTS
|
||||
PROMPT **************************************
|
||||
SELECT e.owner,
|
||||
e.segment_type,
|
||||
Substr(e.segment_name, 1, 30) segment_name,
|
||||
Trunc(s.initial_extent/1024) "INITIAL K",
|
||||
Trunc(s.next_extent/1024) "NEXT K",
|
||||
s.max_extents,
|
||||
Count(*) as extents
|
||||
FROM dba_extents e,
|
||||
dba_segments s
|
||||
WHERE e.owner = s.owner
|
||||
AND e.segment_name = s.segment_name
|
||||
AND e.owner NOT IN ('SYS', 'SYSTEM')
|
||||
GROUP BY e.owner, e.segment_type, e.segment_name, s.initial_extent, s.next_extent, s.max_extents
|
||||
HAVING Count(*) > s.max_extents - 10
|
||||
ORDER BY e.owner, e.segment_type, Count(*) DESC;
|
||||
34
timhall/monitoring/min_datafile_size.sql
Normal file
34
timhall/monitoring/min_datafile_size.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : http://www.oracle-base.com/dba/monitoring/min_datafile_size.sql
|
||||
-- Author : DR Timothy S Hall
|
||||
-- Description : Displays smallest size the datafiles can shrink to without a reorg.
|
||||
-- Requirements : Access to the V$ and DBA views.
|
||||
-- Call Syntax : @min_datafile_size
|
||||
-- Last Modified: 07/09/2007
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
COLUMN block_size NEW_VALUE v_block_size
|
||||
|
||||
SELECT TO_NUMBER(value) AS block_size
|
||||
FROM v$parameter
|
||||
WHERE name = 'db_block_size';
|
||||
|
||||
COLUMN tablespace_name FORMAT A20
|
||||
COLUMN file_name FORMAT A50
|
||||
COLUMN current_bytes FORMAT 999999999999999
|
||||
COLUMN shrink_by_bytes FORMAT 999999999999999
|
||||
COLUMN resize_to_bytes FORMAT 999999999999999
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 200
|
||||
|
||||
SELECT a.tablespace_name,
|
||||
a.file_name,
|
||||
a.bytes AS current_bytes,
|
||||
a.bytes - b.resize_to AS shrink_by_bytes,
|
||||
b.resize_to AS resize_to_bytes
|
||||
FROM dba_data_files a,
|
||||
(SELECT file_id, MAX((block_id+blocks-1)*&v_block_size) AS resize_to
|
||||
FROM dba_extents
|
||||
GROUP by file_id) b
|
||||
WHERE a.file_id = b.file_id
|
||||
ORDER BY a.tablespace_name, a.file_name;
|
||||
35
timhall/monitoring/monitor.sql
Normal file
35
timhall/monitoring/monitor.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/monitor.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays SQL statements for the current database sessions.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @monitor
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
SET LINESIZE 255
|
||||
COL SID FORMAT 999
|
||||
COL STATUS FORMAT A8
|
||||
COL PROCESS FORMAT A10
|
||||
COL SCHEMANAME FORMAT A16
|
||||
COL OSUSER FORMAT A16
|
||||
COL SQL_TEXT FORMAT A120 HEADING 'SQL QUERY'
|
||||
COL PROGRAM FORMAT A30
|
||||
|
||||
SELECT s.sid,
|
||||
s.status,
|
||||
s.process,
|
||||
s.schemaname,
|
||||
s.osuser,
|
||||
a.sql_text,
|
||||
p.program
|
||||
FROM v$session s,
|
||||
v$sqlarea a,
|
||||
v$process p
|
||||
WHERE s.SQL_HASH_VALUE = a.HASH_VALUE
|
||||
AND s.SQL_ADDRESS = a.ADDRESS
|
||||
AND s.PADDR = p.ADDR
|
||||
/
|
||||
|
||||
SET VERIFY ON
|
||||
SET LINESIZE 255
|
||||
25
timhall/monitoring/monitor_memory.sql
Normal file
25
timhall/monitoring/monitor_memory.sql
Normal file
@@ -0,0 +1,25 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/monitor_memory.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays memory allocations for the current database sessions.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @monitor_memory
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
COLUMN username FORMAT A20
|
||||
COLUMN module FORMAT A20
|
||||
|
||||
SELECT NVL(a.username,'(oracle)') AS username,
|
||||
a.module,
|
||||
a.program,
|
||||
Trunc(b.value/1024) AS memory_kb
|
||||
FROM v$session a,
|
||||
v$sesstat b,
|
||||
v$statname c
|
||||
WHERE a.sid = b.sid
|
||||
AND b.statistic# = c.statistic#
|
||||
AND c.name = 'session pga memory'
|
||||
AND a.program IS NOT NULL
|
||||
ORDER BY b.value DESC;
|
||||
13
timhall/monitoring/monitoring_status.sql
Normal file
13
timhall/monitoring/monitoring_status.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/monitoring_status.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Shows the monitoring status for the specified tables.
|
||||
-- Call Syntax : @monitoring_status (schema) (table-name or all)
|
||||
-- Last Modified: 21/03/2003
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT table_name, monitoring
|
||||
FROM dba_tables
|
||||
WHERE owner = UPPER('&1')
|
||||
AND table_name = DECODE(UPPER('&2'), 'ALL', table_name, UPPER('&2'));
|
||||
20
timhall/monitoring/nls_params.sql
Normal file
20
timhall/monitoring/nls_params.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/nls_params.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays National Language Suppport (NLS) information.
|
||||
-- Requirements :
|
||||
-- Call Syntax : @nls_params
|
||||
-- Last Modified: 21-FEB-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 100
|
||||
COLUMN parameter FORMAT A45
|
||||
COLUMN value FORMAT A45
|
||||
|
||||
PROMPT *** Database parameters ***
|
||||
SELECT * FROM nls_database_parameters ORDER BY 1;
|
||||
|
||||
PROMPT *** Instance parameters ***
|
||||
SELECT * FROM nls_instance_parameters ORDER BY 1;
|
||||
|
||||
PROMPT *** Session parameters ***
|
||||
SELECT * FROM nls_session_parameters ORDER BY 1;
|
||||
33
timhall/monitoring/non_indexed_fks.sql
Normal file
33
timhall/monitoring/non_indexed_fks.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/non_indexed_fks.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of non-indexes FKs.
|
||||
-- Requirements : Access to the ALL views.
|
||||
-- Call Syntax : @non_indexed_fks
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
SET PAGESIZE 1000
|
||||
SET LINESIZE 255
|
||||
SET FEEDBACK OFF
|
||||
|
||||
SELECT t.table_name,
|
||||
c.constraint_name,
|
||||
c.table_name table2,
|
||||
acc.column_name
|
||||
FROM all_constraints t,
|
||||
all_constraints c,
|
||||
all_cons_columns acc
|
||||
WHERE c.r_constraint_name = t.constraint_name
|
||||
AND c.table_name = acc.table_name
|
||||
AND c.constraint_name = acc.constraint_name
|
||||
AND NOT EXISTS (SELECT '1'
|
||||
FROM all_ind_columns aid
|
||||
WHERE aid.table_name = acc.table_name
|
||||
AND aid.column_name = acc.column_name)
|
||||
ORDER BY c.table_name;
|
||||
|
||||
|
||||
PROMPT
|
||||
SET FEEDBACK ON
|
||||
SET PAGESIZE 18
|
||||
16
timhall/monitoring/obj_lock.sql
Normal file
16
timhall/monitoring/obj_lock.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/obj_lock.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of locked objects.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @obj_lock
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SELECT a.type,
|
||||
Substr(a.owner,1,30) owner,
|
||||
a.sid,
|
||||
Substr(a.object,1,30) object
|
||||
FROM v$access a
|
||||
WHERE a.owner NOT IN ('SYS','PUBLIC')
|
||||
ORDER BY 1,2,3,4
|
||||
/
|
||||
28
timhall/monitoring/object_privs.sql
Normal file
28
timhall/monitoring/object_privs.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/object_privs.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays object privileges on a specified object.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @object_privs (owner) (object-name)
|
||||
-- Last Modified: 27/07/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200 VERIFY OFF
|
||||
|
||||
COLUMN owner FORMAT A30
|
||||
COLUMN object_name FORMAT A30
|
||||
COLUMN grantor FORMAT A30
|
||||
COLUMN grantee FORMAT A30
|
||||
|
||||
SELECT owner,
|
||||
table_name AS object_name,
|
||||
grantor,
|
||||
grantee,
|
||||
privilege,
|
||||
grantable,
|
||||
hierarchy
|
||||
FROM dba_tab_privs
|
||||
WHERE owner = UPPER('&1')
|
||||
AND table_name = UPPER('&2')
|
||||
ORDER BY 1,2,3,4;
|
||||
|
||||
SET VERIFY ON
|
||||
23
timhall/monitoring/object_status.sql
Normal file
23
timhall/monitoring/object_status.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/object_status.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of objects and their status for the specific schema.
|
||||
-- Requirements : Access to the ALL views.
|
||||
-- Call Syntax : @object_status (schema-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
SET PAGESIZE 1000
|
||||
SET LINESIZE 255
|
||||
SET FEEDBACK OFF
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT Substr(object_name,1,30) object_name,
|
||||
object_type,
|
||||
status
|
||||
FROM all_objects
|
||||
WHERE owner = Upper('&&1');
|
||||
|
||||
PROMPT
|
||||
SET FEEDBACK ON
|
||||
SET PAGESIZE 18
|
||||
34
timhall/monitoring/objects.sql
Normal file
34
timhall/monitoring/objects.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/objects.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all database objects.
|
||||
-- Requirements : Access to the dba_objects view.
|
||||
-- Call Syntax : @objects [ object-name | % (for all)]
|
||||
-- Last Modified: 21-FEB-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200 VERIFY OFF
|
||||
|
||||
COLUMN owner FORMAT A20
|
||||
COLUMN object_name FORMAT A30
|
||||
COLUMN edition_name FORMAT A15
|
||||
|
||||
SELECT owner,
|
||||
object_name,
|
||||
--subobject_name,
|
||||
object_id,
|
||||
data_object_id,
|
||||
object_type,
|
||||
TO_CHAR(created, 'DD-MON-YYYY HH24:MI:SS') AS created,
|
||||
TO_CHAR(last_ddl_time, 'DD-MON-YYYY HH24:MI:SS') AS last_ddl_time,
|
||||
timestamp,
|
||||
status,
|
||||
temporary,
|
||||
generated,
|
||||
secondary,
|
||||
--namespace,
|
||||
edition_name
|
||||
FROM dba_objects
|
||||
WHERE UPPER(object_name) LIKE UPPER('%&1%')
|
||||
ORDER BY owner, object_name;
|
||||
|
||||
SET VERIFY ON
|
||||
14
timhall/monitoring/open_cursors.sql
Normal file
14
timhall/monitoring/open_cursors.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/open_cursors.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all cursors currently open.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @open_cursors
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SELECT a.user_name,
|
||||
a.sid,
|
||||
a.sql_text
|
||||
FROM v$open_cursor a
|
||||
ORDER BY 1,2
|
||||
/
|
||||
20
timhall/monitoring/open_cursors_by_sid.sql
Normal file
20
timhall/monitoring/open_cursors_by_sid.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/open_cursors_by_sid.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the SQL statement held for a specific SID.
|
||||
-- Comments : The SID can be found by running session.sql or top_session.sql.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @open_cursors_by_sid (sid)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT oc.sql_text, cursor_type
|
||||
FROM v$open_cursor oc
|
||||
WHERE oc.sid = &1
|
||||
ORDER BY cursor_type;
|
||||
|
||||
PROMPT
|
||||
SET PAGESIZE 14
|
||||
23
timhall/monitoring/open_cursors_full_by_sid.sql
Normal file
23
timhall/monitoring/open_cursors_full_by_sid.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/open_cursors_full_by_sid.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the SQL statement held for a specific SID.
|
||||
-- Comments : The SID can be found by running session.sql or top_session.sql.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @open_cursors_full_by_sid (sid)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT st.sql_text
|
||||
FROM v$sqltext st,
|
||||
v$open_cursor oc
|
||||
WHERE st.address = oc.address
|
||||
AND st.hash_value = oc.hash_value
|
||||
AND oc.sid = &1
|
||||
ORDER BY st.address, st.piece;
|
||||
|
||||
PROMPT
|
||||
SET PAGESIZE 14
|
||||
14
timhall/monitoring/options.sql
Normal file
14
timhall/monitoring/options.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/options.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all database options.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @options
|
||||
-- Last Modified: 12/04/2013
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
COLUMN value FORMAT A20
|
||||
|
||||
SELECT *
|
||||
FROM v$option
|
||||
ORDER BY parameter;
|
||||
17
timhall/monitoring/param_valid_values.sql
Normal file
17
timhall/monitoring/param_valid_values.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/param_valid_values.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists all valid values for the specified parameter.
|
||||
-- Call Syntax : @param_valid_values (parameter-name)
|
||||
-- Requirements : Access to the v$views.
|
||||
-- Last Modified: 14/05/2013
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN value FORMAT A50
|
||||
COLUMN isdefault FORMAT A10
|
||||
|
||||
SELECT value,
|
||||
isdefault
|
||||
FROM v$parameter_valid_values
|
||||
WHERE name = '&1';
|
||||
27
timhall/monitoring/parameter_diffs.sql
Normal file
27
timhall/monitoring/parameter_diffs.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/parameter_diffs.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays parameter values that differ between the current value and the spfile.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @parameter_diffs
|
||||
-- Last Modified: 08-NOV-2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET LINESIZE 120
|
||||
COLUMN name FORMAT A30
|
||||
COLUMN current_value FORMAT A30
|
||||
COLUMN sid FORMAT A8
|
||||
COLUMN spfile_value FORMAT A30
|
||||
|
||||
SELECT p.name,
|
||||
i.instance_name AS sid,
|
||||
p.value AS current_value,
|
||||
sp.sid,
|
||||
sp.value AS spfile_value
|
||||
FROM v$spparameter sp,
|
||||
v$parameter p,
|
||||
v$instance i
|
||||
WHERE sp.name = p.name
|
||||
AND sp.value != p.value;
|
||||
|
||||
COLUMN FORMAT DEFAULT
|
||||
22
timhall/monitoring/parameters.sql
Normal file
22
timhall/monitoring/parameters.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/parameters.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all the parameters.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @parameters
|
||||
-- Last Modified: 15-JUL-2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
|
||||
COLUMN name FORMAT A30
|
||||
COLUMN value FORMAT A60
|
||||
|
||||
SELECT p.name,
|
||||
p.type,
|
||||
p.value,
|
||||
p.isses_modifiable,
|
||||
p.issys_modifiable,
|
||||
p.isinstance_modifiable
|
||||
FROM v$parameter p
|
||||
ORDER BY p.name;
|
||||
|
||||
17
timhall/monitoring/parameters_non_default.sql
Normal file
17
timhall/monitoring/parameters_non_default.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/parameters_non_default.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all the non-default parameters.
|
||||
-- Requirements : Access to the v$ views.
|
||||
-- Call Syntax : @parameters_non_default
|
||||
-- Last Modified: 11-JAN-2017
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 150
|
||||
|
||||
COLUMN name FORMAT A50
|
||||
COLUMN value FORMAT A50
|
||||
|
||||
SELECT name,
|
||||
value
|
||||
FROM v$parameter
|
||||
WHERE isdefault = 'FALSE';
|
||||
13
timhall/monitoring/part_tables.sql
Normal file
13
timhall/monitoring/part_tables.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/part_tables.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about all partitioned tables.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @part_tables
|
||||
-- Last Modified: 21/12/2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SELECT owner, table_name, partitioning_type, partition_count
|
||||
FROM dba_part_tables
|
||||
WHERE owner NOT IN ('SYS', 'SYSTEM')
|
||||
ORDER BY owner, table_name;
|
||||
13
timhall/monitoring/pga_target_advice.sql
Normal file
13
timhall/monitoring/pga_target_advice.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/pga_target_advice.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Predicts how changes to the PGA_AGGREGATE_TARGET will affect PGA usage.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @pga_target_advice
|
||||
-- Last Modified: 12/02/2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SELECT ROUND(pga_target_for_estimate/1024/1024) target_mb,
|
||||
estd_pga_cache_hit_percentage cache_hit_perc,
|
||||
estd_overalloc_count
|
||||
FROM v$pga_target_advice;
|
||||
19
timhall/monitoring/pipes.sql
Normal file
19
timhall/monitoring/pipes.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/pipes.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all database pipes.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @pipes
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 100
|
||||
|
||||
COLUMN name FORMAT A40
|
||||
|
||||
SELECT ownerid,
|
||||
name,
|
||||
type,
|
||||
pipe_size
|
||||
FROM v$db_pipes
|
||||
ORDER BY 1,2;
|
||||
|
||||
33
timhall/monitoring/profiler_run_details.sql
Normal file
33
timhall/monitoring/profiler_run_details.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/profiler_run_details.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays details of a specified profiler run.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @profiler_run_details.sql (runid)
|
||||
-- Last Modified: 25/02/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN runid FORMAT 99999
|
||||
COLUMN unit_number FORMAT 99999
|
||||
COLUMN unit_type FORMAT A20
|
||||
COLUMN unit_owner FORMAT A20
|
||||
|
||||
SELECT u.runid,
|
||||
u.unit_number,
|
||||
u.unit_type,
|
||||
u.unit_owner,
|
||||
u.unit_name,
|
||||
d.line#,
|
||||
d.total_occur,
|
||||
ROUND(d.total_time/d.total_occur) as time_per_occur,
|
||||
d.total_time,
|
||||
d.min_time,
|
||||
d.max_time
|
||||
FROM plsql_profiler_units u
|
||||
JOIN plsql_profiler_data d ON u.runid = d.runid AND u.unit_number = d.unit_number
|
||||
WHERE u.runid = &1
|
||||
AND d.total_time > 0
|
||||
AND d.total_occur > 0
|
||||
ORDER BY (d.total_time/d.total_occur) DESC, u.unit_number, d.line#;
|
||||
20
timhall/monitoring/profiler_runs.sql
Normal file
20
timhall/monitoring/profiler_runs.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/profiler_runs.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all profiler_runs.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @profiler_runs.sql
|
||||
-- Last Modified: 25/02/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
SET TRIMOUT ON
|
||||
|
||||
COLUMN runid FORMAT 99999
|
||||
COLUMN run_comment FORMAT A50
|
||||
|
||||
SELECT runid,
|
||||
run_date,
|
||||
run_comment,
|
||||
run_total_time
|
||||
FROM plsql_profiler_runs
|
||||
ORDER BY runid;
|
||||
26
timhall/monitoring/profiles.sql
Normal file
26
timhall/monitoring/profiles.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/profiles.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the specified profile(s).
|
||||
-- Call Syntax : @profiles (profile | part of profile | all)
|
||||
-- Last Modified: 28/01/2006
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET LINESIZE 150 PAGESIZE 20 VERIFY OFF
|
||||
|
||||
BREAK ON profile SKIP 1
|
||||
|
||||
COLUMN profile FORMAT A35
|
||||
COLUMN resource_name FORMAT A40
|
||||
COLUMN limit FORMAT A15
|
||||
|
||||
SELECT profile,
|
||||
resource_type,
|
||||
resource_name,
|
||||
limit
|
||||
FROM dba_profiles
|
||||
WHERE profile LIKE (DECODE(UPPER('&1'), 'ALL', '%', UPPER('%&1%')))
|
||||
ORDER BY profile, resource_type, resource_name;
|
||||
|
||||
CLEAR BREAKS
|
||||
SET LINESIZE 80 PAGESIZE 14 VERIFY ON
|
||||
20
timhall/monitoring/proxy_users.sql
Normal file
20
timhall/monitoring/proxy_users.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/proxy_users.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about proxy users.
|
||||
-- Requirements : Access to the PROXY_USERS views.
|
||||
-- Call Syntax : @proxy_users.sql {username or %}
|
||||
-- Last Modified: 02/06/2020
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN proxy FORMAT A30
|
||||
COLUMN client FORMAT A30
|
||||
|
||||
SELECT proxy,
|
||||
client,
|
||||
authentication,
|
||||
flags
|
||||
FROM proxy_users
|
||||
WHERE proxy LIKE UPPER('%&1%');
|
||||
35
timhall/monitoring/rbs_extents.sql
Normal file
35
timhall/monitoring/rbs_extents.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/rbs_extents.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about the rollback segment extents.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @rbs_extents
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT Substr(a.segment_name,1,30) "Segment Name",
|
||||
b.status "Status",
|
||||
Count(*) "Extents",
|
||||
b.max_extents "Max Extents",
|
||||
Trunc(b.initial_extent/1024) "Initial Extent (Kb)",
|
||||
Trunc(b.next_extent/1024) "Next Extent (Kb)",
|
||||
Trunc(c.bytes/1024) "Size (Kb)"
|
||||
FROM dba_extents a,
|
||||
dba_rollback_segs b,
|
||||
dba_segments c
|
||||
WHERE a.segment_type = 'ROLLBACK'
|
||||
AND b.segment_name = a.segment_name
|
||||
AND b.segment_name = c.segment_name
|
||||
GROUP BY a.segment_name,
|
||||
b.status,
|
||||
b.max_extents,
|
||||
b.initial_extent,
|
||||
b.next_extent,
|
||||
c.bytes
|
||||
ORDER BY a.segment_name;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
28
timhall/monitoring/rbs_stats.sql
Normal file
28
timhall/monitoring/rbs_stats.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/rbs_stats.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays rollback segment statistics.
|
||||
-- Requirements : Access to the v$ & DBA views.
|
||||
-- Call Syntax : @rbs_stats
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT b.name "Segment Name",
|
||||
Trunc(c.bytes/1024) "Size (Kb)",
|
||||
a.optsize "Optimal",
|
||||
a.shrinks "Shrinks",
|
||||
a.aveshrink "Avg Shrink",
|
||||
a.wraps "Wraps",
|
||||
a.extends "Extends"
|
||||
FROM v$rollstat a,
|
||||
v$rollname b,
|
||||
dba_segments c
|
||||
WHERE a.usn = b.usn
|
||||
AND b.name = c.segment_name
|
||||
ORDER BY b.name;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
20
timhall/monitoring/recovery_status.sql
Normal file
20
timhall/monitoring/recovery_status.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/recovery_status.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the recovery status of each datafile.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @recovery_status
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 500
|
||||
SET FEEDBACK OFF
|
||||
|
||||
SELECT Substr(a.name,1,60) "Datafile",
|
||||
b.status "Status"
|
||||
FROM v$datafile a,
|
||||
v$backup b
|
||||
WHERE a.file# = b.file#;
|
||||
|
||||
SET PAGESIZE 14
|
||||
SET FEEDBACK ON
|
||||
23
timhall/monitoring/recyclebin.sql
Normal file
23
timhall/monitoring/recyclebin.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/recyclebin.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays the contents of the recyclebin.
|
||||
-- Requirements : Access to the DBA views. Depending on DB version, different columns
|
||||
-- are available.
|
||||
-- Call Syntax : @recyclebin (owner | all)
|
||||
-- Last Modified: 15/07/2010
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500 VERIFY OFF
|
||||
|
||||
SELECT owner,
|
||||
original_name,
|
||||
object_name,
|
||||
operation,
|
||||
type,
|
||||
space AS space_blks,
|
||||
ROUND((space*8)/1024,2) space_mb
|
||||
FROM dba_recyclebin
|
||||
WHERE owner = DECODE(UPPER('&1'), 'ALL', owner, UPPER('&1'))
|
||||
ORDER BY 1, 2;
|
||||
|
||||
SET VERIFY ON
|
||||
19
timhall/monitoring/redo_by_day.sql
Normal file
19
timhall/monitoring/redo_by_day.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/redo_by_day.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists the volume of archived redo by day for the specified number of days.
|
||||
-- Call Syntax : @redo_by_day (days)
|
||||
-- Requirements : Access to the v$views.
|
||||
-- Last Modified: 11/10/2013
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT TRUNC(first_time) AS day,
|
||||
ROUND(SUM(blocks * block_size)/1024/1024/1024,2) size_gb
|
||||
FROM v$archived_log
|
||||
WHERE TRUNC(first_time) >= TRUNC(SYSDATE) - &1
|
||||
GROUP BY TRUNC(first_time)
|
||||
ORDER BY TRUNC(first_time);
|
||||
|
||||
SET VERIFY ON
|
||||
24
timhall/monitoring/redo_by_hour.sql
Normal file
24
timhall/monitoring/redo_by_hour.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/redo_by_hour.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists the volume of archived redo by hour for the specified day.
|
||||
-- Call Syntax : @redo_by_hour (day 0=Today, 1=Yesterday etc.)
|
||||
-- Requirements : Access to the v$views.
|
||||
-- Last Modified: 11/10/2013
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET VERIFY OFF PAGESIZE 30
|
||||
|
||||
WITH hours AS (
|
||||
SELECT TRUNC(SYSDATE) - &1 + ((level-1)/24) AS hours
|
||||
FROM dual
|
||||
CONNECT BY level < = 24
|
||||
)
|
||||
SELECT h.hours AS date_hour,
|
||||
ROUND(SUM(blocks * block_size)/1024/1024/1024,2) size_gb
|
||||
FROM hours h
|
||||
LEFT OUTER JOIN v$archived_log al ON h.hours = TRUNC(al.first_time, 'HH24')
|
||||
GROUP BY h.hours
|
||||
ORDER BY h.hours;
|
||||
|
||||
SET VERIFY ON PAGESIZE 14
|
||||
24
timhall/monitoring/redo_by_min.sql
Normal file
24
timhall/monitoring/redo_by_min.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/redo_by_min.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists the volume of archived redo by min for the specified number of hours.
|
||||
-- Call Syntax : @redo_by_min (N number of minutes from now)
|
||||
-- Requirements : Access to the v$views.
|
||||
-- Last Modified: 11/10/2013
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET VERIFY OFF PAGESIZE 100
|
||||
|
||||
WITH mins AS (
|
||||
SELECT TRUNC(SYSDATE, 'MI') - (&1/(24*60)) + ((level-1)/(24*60)) AS mins
|
||||
FROM dual
|
||||
CONNECT BY level <= &1
|
||||
)
|
||||
SELECT m.mins AS date_min,
|
||||
ROUND(SUM(blocks * block_size)/1024/1024,2) size_mb
|
||||
FROM mins m
|
||||
LEFT OUTER JOIN v$archived_log al ON m.mins = TRUNC(al.first_time, 'MI')
|
||||
GROUP BY m.mins
|
||||
ORDER BY m.mins;
|
||||
|
||||
SET VERIFY ON PAGESIZE 14
|
||||
26
timhall/monitoring/registry_history.sql
Normal file
26
timhall/monitoring/registry_history.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/registry_history.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays contents of the registry history
|
||||
-- Requirements : Access to the DBA role.
|
||||
-- Call Syntax : @registry_history
|
||||
-- Last Modified: 23/08/2008
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
COLUMN action_time FORMAT A20
|
||||
COLUMN action FORMAT A20
|
||||
COLUMN namespace FORMAT A20
|
||||
COLUMN version FORMAT A10
|
||||
COLUMN comments FORMAT A30
|
||||
COLUMN bundle_series FORMAT A10
|
||||
|
||||
SELECT TO_CHAR(action_time, 'DD-MON-YYYY HH24:MI:SS') AS action_time,
|
||||
action,
|
||||
namespace,
|
||||
version,
|
||||
id,
|
||||
comments,
|
||||
bundle_series
|
||||
FROM sys.registry$history
|
||||
ORDER by action_time;
|
||||
44
timhall/monitoring/role_privs.sql
Normal file
44
timhall/monitoring/role_privs.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/role_privs.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all roles and privileges granted to the specified role.
|
||||
-- Requirements : Access to the USER views.
|
||||
-- Call Syntax : @role_privs (role-name, ALL)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT a.role,
|
||||
a.granted_role,
|
||||
a.admin_option
|
||||
FROM role_role_privs a
|
||||
WHERE a.role = DECODE(UPPER('&1'), 'ALL', a.role, UPPER('&1'))
|
||||
ORDER BY a.role, a.granted_role;
|
||||
|
||||
SELECT a.grantee,
|
||||
a.granted_role,
|
||||
a.admin_option,
|
||||
a.default_role
|
||||
FROM dba_role_privs a
|
||||
WHERE a.grantee = DECODE(UPPER('&1'), 'ALL', a.grantee, UPPER('&1'))
|
||||
ORDER BY a.grantee, a.granted_role;
|
||||
|
||||
SELECT a.role,
|
||||
a.privilege,
|
||||
a.admin_option
|
||||
FROM role_sys_privs a
|
||||
WHERE a.role = DECODE(UPPER('&1'), 'ALL', a.role, UPPER('&1'))
|
||||
ORDER BY a.role, a.privilege;
|
||||
|
||||
SELECT a.role,
|
||||
a.owner,
|
||||
a.table_name,
|
||||
a.column_name,
|
||||
a.privilege,
|
||||
a.grantable
|
||||
FROM role_tab_privs a
|
||||
WHERE a.role = DECODE(UPPER('&1'), 'ALL', a.role, UPPER('&1'))
|
||||
ORDER BY a.role, a.owner, a.table_name;
|
||||
|
||||
SET VERIFY ON
|
||||
20
timhall/monitoring/roles.sql
Normal file
20
timhall/monitoring/roles.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/roles.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all roles and privileges granted to the specified user.
|
||||
-- Requirements : Access to the USER views.
|
||||
-- Call Syntax : @roles
|
||||
-- Last Modified: 27/02/2018
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET SERVEROUTPUT ON
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN role FORMAT A30
|
||||
|
||||
SELECT a.role,
|
||||
a.password_required,
|
||||
a.authentication_type
|
||||
FROM dba_roles a
|
||||
ORDER BY a.role;
|
||||
|
||||
SET VERIFY ON
|
||||
26
timhall/monitoring/search_source.sql
Normal file
26
timhall/monitoring/search_source.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/search_source.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays a list of all code-objects that contain the specified word.
|
||||
-- Requirements : Access to the ALL views.
|
||||
-- Call Syntax : @search_source (text) (schema-name)
|
||||
-- Last Modified: 15/07/2000
|
||||
-- -----------------------------------------------------------------------------------
|
||||
BREAK ON Name Skip 2
|
||||
SET PAGESIZE 0
|
||||
SET LINESIZE 500
|
||||
SET VERIFY OFF
|
||||
|
||||
SPOOL Search_Source.txt
|
||||
|
||||
SELECT a.name "Name",
|
||||
a.line "Line",
|
||||
Substr(a.text,1,200) "Text"
|
||||
FROM all_source a
|
||||
WHERE Instr(Upper(a.text),Upper('&&1')) != 0
|
||||
AND a.owner = Upper('&&2')
|
||||
ORDER BY 1,2;
|
||||
|
||||
SPOOL OFF
|
||||
SET PAGESIZE 14
|
||||
SET VERIFY ON
|
||||
22
timhall/monitoring/segment_size.sql
Normal file
22
timhall/monitoring/segment_size.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/segment_size.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays size of specified segment.
|
||||
-- Requirements : Access to the DBA views.
|
||||
-- Call Syntax : @segment_size (owner) (segment_name)
|
||||
-- Last Modified: 15/07/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500 VERIFY OFF
|
||||
COLUMN segment_name FORMAT A30
|
||||
|
||||
SELECT owner,
|
||||
segment_name,
|
||||
segment_type,
|
||||
tablespace_name,
|
||||
ROUND(bytes/1024/1024,2) size_mb
|
||||
FROM dba_segments
|
||||
WHERE owner = UPPER('&1')
|
||||
AND segment_name LIKE '%' || UPPER('&2') || '%'
|
||||
ORDER BY 1, 2;
|
||||
|
||||
SET VERIFY ON
|
||||
24
timhall/monitoring/segment_stats.sql
Normal file
24
timhall/monitoring/segment_stats.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : http://www.oracle-base.com/dba/monitoring/segment_stats.sql
|
||||
-- Author : DR Timothy S Hall
|
||||
-- Description : Displays statistics for segments in th specified schema.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @segment_stats
|
||||
-- Last Modified: 20/10/2006
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SELECT statistic#,
|
||||
name
|
||||
FROM v$segstat_name
|
||||
ORDER BY statistic#;
|
||||
|
||||
ACCEPT l_schema char PROMPT 'Enter Schema: '
|
||||
ACCEPT l_stat NUMBER PROMPT 'Enter Statistic#: '
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT object_name,
|
||||
object_type,
|
||||
value
|
||||
FROM v$segment_statistics
|
||||
WHERE owner = UPPER('&l_schema')
|
||||
AND statistic# = &l_stat
|
||||
ORDER BY value;
|
||||
23
timhall/monitoring/segments_in_ts.sql
Normal file
23
timhall/monitoring/segments_in_ts.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/segments_in_ts.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Lists the objects stored in a tablespace.
|
||||
-- Call Syntax : @objects_in_ts (tablespace-name)
|
||||
-- Last Modified: 15/06/2018
|
||||
-- -----------------------------------------------------------------------------------
|
||||
|
||||
SET PAGESIZE 20
|
||||
BREAK ON segment_type SKIP 1
|
||||
|
||||
COLUMN segment_name FORMAT A30
|
||||
COLUMN partition_name FORMAT A30
|
||||
|
||||
SELECT segment_type,
|
||||
segment_name,
|
||||
partition_name,
|
||||
ROUND(bytes/2014/1024,2) AS size_mb
|
||||
FROM dba_segments
|
||||
WHERE tablespace_name = UPPER('&1')
|
||||
ORDER BY 1, 2;
|
||||
|
||||
CLEAR BREAKS
|
||||
30
timhall/monitoring/session_events.sql
Normal file
30
timhall/monitoring/session_events.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_events.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all database session events.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_events
|
||||
-- Last Modified: 11/03/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN username FORMAT A20
|
||||
COLUMN event FORMAT A40
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
se.event,
|
||||
se.total_waits,
|
||||
se.total_timeouts,
|
||||
se.time_waited,
|
||||
se.average_wait,
|
||||
se.max_wait,
|
||||
se.time_waited_micro
|
||||
FROM v$session_event se,
|
||||
v$session s
|
||||
WHERE s.sid = se.sid
|
||||
AND s.sid = &1
|
||||
ORDER BY se.time_waited DESC;
|
||||
31
timhall/monitoring/session_events_by_sid.sql
Normal file
31
timhall/monitoring/session_events_by_sid.sql
Normal file
@@ -0,0 +1,31 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_events_by_sid.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all database session events for the specified sid.
|
||||
-- This is a rename of session_events.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_events_by_sid (sid)
|
||||
-- Last Modified: 06-APR-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN username FORMAT A20
|
||||
COLUMN event FORMAT A40
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
se.event,
|
||||
se.total_waits,
|
||||
se.total_timeouts,
|
||||
se.time_waited,
|
||||
se.average_wait,
|
||||
se.max_wait,
|
||||
se.time_waited_micro
|
||||
FROM v$session_event se,
|
||||
v$session s
|
||||
WHERE s.sid = se.sid
|
||||
AND s.sid = &1
|
||||
ORDER BY se.time_waited DESC;
|
||||
32
timhall/monitoring/session_events_by_spid.sql
Normal file
32
timhall/monitoring/session_events_by_spid.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_events_by_spid.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information on all database session events for the specified spid.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_events_by_spid (spid)
|
||||
-- Last Modified: 06-APR-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
SET PAGESIZE 1000
|
||||
SET VERIFY OFF
|
||||
|
||||
COLUMN username FORMAT A20
|
||||
COLUMN event FORMAT A40
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
se.event,
|
||||
se.total_waits,
|
||||
se.total_timeouts,
|
||||
se.time_waited,
|
||||
se.average_wait,
|
||||
se.max_wait,
|
||||
se.time_waited_micro
|
||||
FROM v$session_event se,
|
||||
v$session s,
|
||||
v$process p
|
||||
WHERE s.sid = se.sid
|
||||
AND s.paddr = p.addr
|
||||
AND p.spid = &1
|
||||
ORDER BY se.time_waited DESC;
|
||||
28
timhall/monitoring/session_io.sql
Normal file
28
timhall/monitoring/session_io.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_io.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays I/O information on all database sessions.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_io
|
||||
-- Last Modified: 21-FEB-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
|
||||
COLUMN username FORMAT A15
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.osuser,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
si.block_gets,
|
||||
si.consistent_gets,
|
||||
si.physical_reads,
|
||||
si.block_changes,
|
||||
si.consistent_changes
|
||||
FROM v$session s,
|
||||
v$sess_io si
|
||||
WHERE s.sid = si.sid
|
||||
ORDER BY s.username, s.osuser;
|
||||
|
||||
SET PAGESIZE 14
|
||||
46
timhall/monitoring/session_pga.sql
Normal file
46
timhall/monitoring/session_pga.sql
Normal file
@@ -0,0 +1,46 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_pga.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays information about PGA usage for each session.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_pga
|
||||
-- Last Modified: 21-FEB-2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 500
|
||||
SET PAGESIZE 1000
|
||||
|
||||
COLUMN username FORMAT A30
|
||||
COLUMN osuser FORMAT A20
|
||||
COLUMN spid FORMAT A10
|
||||
COLUMN service_name FORMAT A15
|
||||
COLUMN module FORMAT A45
|
||||
COLUMN machine FORMAT A30
|
||||
COLUMN logon_time FORMAT A20
|
||||
COLUMN pga_used_mem_mb FORMAT 99990.00
|
||||
COLUMN pga_alloc_mem_mb FORMAT 99990.00
|
||||
COLUMN pga_freeable_mem_mb FORMAT 99990.00
|
||||
COLUMN pga_max_mem_mb FORMAT 99990.00
|
||||
|
||||
SELECT NVL(s.username, '(oracle)') AS username,
|
||||
s.osuser,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
p.spid,
|
||||
ROUND(p.pga_used_mem/1024/1024,2) AS pga_used_mem_mb,
|
||||
ROUND(p.pga_alloc_mem/1024/1024,2) AS pga_alloc_mem_mb,
|
||||
ROUND(p.pga_freeable_mem/1024/1024,2) AS pga_freeable_mem_mb,
|
||||
ROUND(p.pga_max_mem/1024/1024,2) AS pga_max_mem_mb,
|
||||
s.lockwait,
|
||||
s.status,
|
||||
s.service_name,
|
||||
s.module,
|
||||
s.machine,
|
||||
s.program,
|
||||
TO_CHAR(s.logon_Time,'DD-MON-YYYY HH24:MI:SS') AS logon_time,
|
||||
s.last_call_et AS last_call_et_secs
|
||||
FROM v$session s,
|
||||
v$process p
|
||||
WHERE s.paddr = p.addr
|
||||
ORDER BY s.username, s.osuser;
|
||||
|
||||
SET PAGESIZE 14
|
||||
28
timhall/monitoring/session_rollback.sql
Normal file
28
timhall/monitoring/session_rollback.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_rollback.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays rollback information on relevant database sessions.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_rollback
|
||||
-- Last Modified: 29/03/2005
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET LINESIZE 200
|
||||
|
||||
COLUMN username FORMAT A15
|
||||
|
||||
SELECT s.username,
|
||||
s.sid,
|
||||
s.serial#,
|
||||
t.used_ublk,
|
||||
t.used_urec,
|
||||
rs.segment_name,
|
||||
r.rssize,
|
||||
r.status
|
||||
FROM v$transaction t,
|
||||
v$session s,
|
||||
v$rollstat r,
|
||||
dba_rollback_segs rs
|
||||
WHERE s.saddr = t.ses_addr
|
||||
AND t.xidusn = r.usn
|
||||
AND rs.segment_id = t.xidusn
|
||||
ORDER BY t.used_ublk DESC;
|
||||
19
timhall/monitoring/session_stats.sql
Normal file
19
timhall/monitoring/session_stats.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- -----------------------------------------------------------------------------------
|
||||
-- File Name : https://oracle-base.com/dba/monitoring/session_stats.sql
|
||||
-- Author : Tim Hall
|
||||
-- Description : Displays session-specific statistics.
|
||||
-- Requirements : Access to the V$ views.
|
||||
-- Call Syntax : @session_stats (statistic-name or all)
|
||||
-- Last Modified: 03/11/2004
|
||||
-- -----------------------------------------------------------------------------------
|
||||
SET VERIFY OFF
|
||||
|
||||
SELECT sn.name, ss.value
|
||||
FROM v$sesstat ss,
|
||||
v$statname sn,
|
||||
v$session s
|
||||
WHERE ss.statistic# = sn.statistic#
|
||||
AND s.sid = ss.sid
|
||||
AND s.audsid = SYS_CONTEXT('USERENV','SESSIONID')
|
||||
AND sn.name LIKE '%' || DECODE(LOWER('&1'), 'all', '', LOWER('&1')) || '%';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user