Believe that anything you can imagine you can achieve it real. Having the devotion,passion and dedication to learn & Work in Oracle field mail me @ rafidba.alvi@gmail.com."Knowledge grows when it is shared". Best Career related guidance in Oracle DBA,Oracle Apps DBA,Oracle SOA Admin/Developers,ODI Developers,OBI Developers and Oracle Designers. "A Catalyst for Oracle DBA & Apps DBA Interviews,Jobs & Career."
Tuesday, February 22, 2011
Oracle R12 Application Architecture
Hi,
We can understand Oracle R12 Application by dividing it into 3 major components:
I)Oracle Applications Architecture
II)Applications File System– Overview
III)Applications Database Organization
I)Oracle Applications Architecture:
Let us see the structure in this post.
Oracle Application can be divided into
1)Desktop Tier
2)The Application Tier
3)The Database Tier
I)Desktop Tier:
*The client interface is provided through HTML for HTML-based applications, and via a Java applet in a Web browser for the traditional Forms-based applications.
*In Oracle Applications Release 12, each user logs in to Oracle Applications through the E-Business Suite Home Page on a desktop client web browser as shown in fig.1.
*The E-Business SuiteHome Page as shown in fig.1 provides a single point of access to HTML-basedapplications,Forms-basedapplications, and Business Intelligence applications.
II)The Application Tier:
*The application tier has a dual role: hosting the various servers and service groups thatprocess the business logic, and managing communication between the desktop tier andthe database tier. This tier is sometimes referred to as the middle tier.
*3 servers or service groups comprise the basic application tier for Oracle Applications:
1)Web services:The Web services component of Oracle Application Server processes requests received over the network from the desktop clients.
2)Forms services:Forms services in Oracle Applications Release 12 are provided by the Forms listener servlet or Form Socket mode,which facilitates the use of firewalls,load balancing,proxies and other networking options.
3)Concurrent services:Processes that run on the Concurrent Processing server are called concurrent requests.A concurrent manager then reads the applicable requests in the table and starts the associated concurrent program
III)The Database Tier:
*The database tier contains the Oracle database server, which stores all the data maintained by Oracle Applications. The database also stores the Oracle Applications online help information.
*More specifically, the database tier contains the Oracle data server files and Oracle Applications database executables that physically store the tables, indexes, and other database objects for your system.
* The database server does not communicate directly with the desktop clients, but rather with the servers on the application tier, which mediate the communications between the database server and the clients.
Hope it helps at initial level of R12 Application undestanding.
Best regards,
Rafi.
Wednesday, February 16, 2011
How index works in oracle
Few days back kavita commented on my post to write about indexes so I found some time to write about indexes.We all know how important are these indexes specially when you have huge data and lot of trasactions are going on and how important they are when it comes to selecting the execution plan for the SQL statements and How important they are for changing the execution plan which optimizer chooses for giving you the desired result in least response time as possible,in order to enhance the performance of your applications.In this brief post I'm discussing how index works in oracle and how can we make use of these indexes to our maximum benefit.
Let me describe the indexes provided by oracle,
Oracle Database provides several indexing schemes.But,
In short there are only 2 types
1)B-tree(Balanced-tree) indexes
2)Bitmap indexes
These 2 types are subdivided as follows:
1)B-tree(Balanced-tree) indexes:
Features of B-tree(Balanced-tree) indexes are as follows:
-----------------------------------------------------------------------------------
These indexes are the standard index type. They are excellent for primary key and highly-selective indexes. Used as concatenated indexes, B-tree indexes can retrieve data sorted by the indexed columns. B-tree indexes have the following subtypes:
*Index-organized tables
An index-organized table differs from a heap-organized because the data is itself the index.
*Reverse key indexes
In this type of index, the bytes of the index key are reversed, for example, 103 is stored as 301. The reversal of bytes spreads out inserts into the index over many blocks.
*Descending indexes
This type of index stores data on a particular column or columns in descending order.
*B-tree cluster indexes
This type of index is used to index a table cluster key. Instead of pointing to a row, the key points to the block that contains rows related to the cluster key.
How B-tree indexes work:
-----------------------------------------
It is very important to know how this indexes actually work to use them to maximum benefit.The mechanism followed by balanced-tree indexes is as follows:
B-tree index has 3 parts:
1)Root
2)Branch blocks
3)Leaf blocks
*Root is the centre-point from where all the branch blocks and leaf blocks is connected.
=>A B-tree index has two types of blocks
1)Branch blocks
2)Leaf blocks
*Branch blocks for searching and leaf blocks that store values.
*Branch blocks store the minimum key prefix needed to make a branching decision between two keys. This technique enables the database to fit as much data as possible on each branch block.
*The branch blocks contain a pointer to the child block containing the key.
The number of keys and pointers is limited by the block size.
*The leaf blocks contain every indexed data value and a corresponding rowid used to locate the actual row. Each entry is sorted by (key, rowid). Within a leaf block, a key and rowid is linked to its left and right sibling entries.
*The branch blooks in one sense is for storing the key value and the leaf block is for sorting as per rowid(As in case of lock if the key is exact the lock will open fast or else it will take time and sorting with rowid is the fastest method to sort data in compare to rownum).
*If the database scans the index for a value, then it will find this value in n I/Os where n is the height of the B-tree index(The height of the index is the number of blocks required to go from the root block to a leaf block).
This is the basic principle behind Oracle Database indexes.
2)Bitmap indexes:
Feautures of Bitmap indexes:
-------------------------------------------------------------------------
*Bitmap and bitmap join indexes
=>In a bitmap index, an index entry uses a bitmap to point to multiple rows.
In contrast, a B-tree index entry points to a single row.This is major difference between
the B-tree and Bitmap indexes.
=>A bitmap join index is a bitmap index for the join of two or more tables.
*Function-based indexes
This type of index includes columns that are either transformed by a function, such as the UPPER function, or included in an expression.
B-tree or bitmap indexes can be function-based.
*Application domain indexes
This type of index is created by a user for data in an application-specific domain. The physical index need not use a traditional index structure and can be stored either in the Oracle database as tables or externally as a file.
How Bitmap indexes work:
--------------------------------------------
*In the Bitmap index the values are stored in the form of 0's and 1's as you see below:
Eg:Bitmap structure might look like this:
Value Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7
M 1 0 1 1 1 0 0
F 0 1 0 0 0 1 1
Where M:male and F:Female represent status for gender
*Each bit in the bitmap corresponds to a possible rowid. If the bit is set, then the row with the corresponding rowid contains the key value.
*A mapping function converts the bit position to an actual rowid, so the bitmap index provides the same functionality as a B-tree index
although it uses a different internal representation.
*Bitmap indexing efficiently merges indexes that correspond to several conditions in a WHERE clause.
*Rows that satisfy some, but not all, conditions are filtered out before the table itself is accessed. This technique improves response time in case of Bitmap indexes.
Difference between B-tree(Balanced tree) and Bitmap indexes:
-------------------------------------------------------------------------------------
1) B-tree indexes index entry points to a single row
Where as,In case of Bitmap indexes index entry point to multiple rows.
2)B-tree indexes are more suitable for high cardinality columns(i.e the number of distinct values is large compared to the number of table rows) eg:ename.
Where as,Bitmap indexes are more suitable for low cardinality columns(i.e the number of distinct values is small compared to the number of table rows) eg:Male or female status for gender.
3)B-tree indexes are used in OLTP environment (eg:Banking Database where there will be huge trasactions taking place).
Where as,Bitmap indexes are primarily designed for data warehousing or environments in which queries reference many columns in an ad hoc fashion(eg:Datawarehouse Database of huge size).
4)In the B-tree indexes actually values are stored in leaves(which is a part of B-tree indexstructure).
Where as,In Bitmap indexes the values are stored in Bits(0's and 1's).
5)In the OLTP environment where there are lot of DML activities are happening it is more advantageous to use B-tree indexes.
Where as,In the OLAP(Datawarehousing) environment or DSS(Decision support system) where we have to perform read only(selecting the data) activities Bitmap indexes are more recommended.
This document is prepared to use indexes to their Best.Hope it helps.
Best regards,
Rafi.
Monday, February 14, 2011
changing oracle database name manually and database id
We can change our Database name manually by peforming below steps as follows:
changing oracle database name:
---------------------------------------------------
Using backup controlfile (Manual Process)
Step 1: Take the backup of your controlfile creation script in trace file.
------
As a first priority for DBA please take the backup of your controlfile
creation script in trace file which is located in udump directory.Switch the logfile
for recent changes to be recorded in logfiles.
SQL> show parameter %user%
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
license_max_users integer 0
parallel_adaptive_multi_user boolean TRUE
user_dump_dest string D:\ADMIN\BOSCHDB\UDUMP
SQL> select name from v$database;
NAME
---------
BOSCHDB
SQL> alter system switch logfile;
System altered.
SQL> alter database backup controlfile to trace;
Database altered.
Step 2: Editing and creating controlfile creation script.
------
We can find the trace file in windows by seeing the most recent modified file which has the naming convention like 'boschdb_ora_2768.trc'.We have to edit this file
by deleting all the lines before 'startup nomount' command,once you do this the actual
control fie creation script will look like as given below:
controlfile_create.sql:
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 'D:\ORADATA\BOSCHDB\REDO01.LOG' SIZE 50M,
GROUP 2 'D:\ORADATA\BOSCHDB\REDO02.LOG' SIZE 50M,
GROUP 3 'D:\ORADATA\BOSCHDB\REDO03.LOG' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'D:\ORADATA\BOSCHDB\SYSTEM01.DBF',
'D:\ORADATA\BOSCHDB\UNDOTBS01.DBF',
'D:\ORADATA\BOSCHDB\SYSAUX01.DBF',
'D:\ORADATA\BOSCHDB\USERS01.DBF',
'D:\ORADATA\BOSCHDB\EXAMPLE01.DBF',
'D:\ORADATA\BOSCHDB\USER123.DBF'
CHARACTER SET WE8MSWIN1252
;
Step 3: Find the control files location and parameter file location.
------
SQL> show parameter %control%
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string D:\ORADATA\BOSCHDB\CONTROL01.C
TL, D:\ORADATA\BOSCHDB\CONTROL
02.CTL, D:\ORADATA\BOSCHDB\CON
TROL03.CTL
My parameter file location is 'D:\admin\BoschDB\pfile' and my parameter file name
is 'init.ora.11172010122445'.
Step 4:Shutdown the instance.
------
We need to shutdown our instance in order to change parameter values i pfile.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Step 5: Change the db_name parameter in the parameter file.
------
Edit the parameter file 'init.ora.11172010122445'(In my experiment) by changing
the value of db_name parameter to TESTDB and save the changes.
###########################################
# Database Identification
###########################################
db_domain=""
db_name=TESTDB
###########################################
Step 6: Create the spfile from pfile.
------
SQL> conn /as sysdba
SQL> create spfile from pfile='D:\admin\BoschDB\pfile\init.ora.11172010122445';
File created.
Step 6:
--------
Create the controlfile by script created in step2 of this experiment as follows:
SQL> @D:\admin\BoschDB\udump\controlfile_create.sql
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1248600 bytes
Variable Size 92275368 bytes
Database Buffers 192937984 bytes
Redo Buffers 2945024 bytes
Control file created.
Step 7: Verify the changes.
------
Once the controlfile gets created our Database as we all know will be in mount
state.We have to open our database with 'resetlogs' option Because The RESETLOGS option is always required after
incomplete media recovery or recovery using a backup control file.
SQL> SELECT STATUS FROM V$INSTANCE;
STATUS
------------
MOUNTED
SQL> SELECT NAME FROM V$DATABASE;
NAME
---------
TESTDB
SQL> ALTER DATABASE OPEN;
ALTER DATABASE OPEN
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> ALTER DATABASE OPEN RESETLOGS;
Database altered.
To make this article complete on demand of Prafull,I'm adding the below steps for changing Database id.
changing DBID(Database id) of Database:
-------------------------------------------------------
Step 1: Set the sid of the Database
-------
As the first you have to set the sid of the Database in the Operating system.I'm doing
it on Windows but for unix also steps almost remain the same accept setting sid.
In Windows: set ORACLE_SID=TESTDB
In Unix environment:export ORACLE_SID=TESTDB
U:\>set ORACLE_SID=TESTDB
step 2: Start the Database
-------
Start the Database with sys user having SYSDBA privilege.
U:\>sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Feb 16 11:29:43 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
step 3: Mount the Database
--------
You have to mount the Database for using DBNEWID utility.
If you don't mount you will get error NID-00121.The error is just for reference.
ERROR:
------
U:\>nid TARGET=/
DBNEWID: Release 10.2.0.1.0 - Production on Wed Feb 16 11:30:05 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database TESTDB (DBID=1762398852)
NID-00121: Database should not be open
Change of database ID failed during validation - database is intact.
DBNEWID - Completed with validation errors.
Let us mount the Database for executing nid command successfully.
SQL> startup mount
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1248600 bytes
Variable Size 96469672 bytes
Database Buffers 188743680 bytes
Redo Buffers 2945024 bytes
Database mounted.
Step 4: Using nid command(DBNEWID utility) for changing DBID(Database id)
--------
Note 1:You have to set SID before using nid command(DBNEWID utility) whose DBID you want to change.
Note 2:Using nid command(DBNEWID utility) you can change database and database id but
in the below example I just changed DBID.
You have to use nid command(DBNEWID utility) for changing the DBID (Database
id ) as follows:
U:\>nid TARGET=/
DBNEWID: Release 10.2.0.1.0 - Production on Wed Feb 16 11:32:07 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database TESTDB (DBID=1762398852)
Connected to server version 10.2.0
Control Files in database:
D:\ORADATA\BOSCHDB\CONTROL01.CTL
D:\ORADATA\BOSCHDB\CONTROL02.CTL
D:\ORADATA\BOSCHDB\CONTROL03.CTL
Change database ID of database TESTDB? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1762398852 to 2526615742
Control File D:\ORADATA\BOSCHDB\CONTROL01.CTL - modified
Control File D:\ORADATA\BOSCHDB\CONTROL02.CTL - modified
Control File D:\ORADATA\BOSCHDB\CONTROL03.CTL - modified
Datafile D:\ORADATA\BOSCHDB\SYSTEM01.DBF - dbid changed
Datafile D:\ORADATA\BOSCHDB\UNDOTBS01.DBF - dbid changed
Datafile D:\ORADATA\BOSCHDB\SYSAUX01.DBF - dbid changed
Datafile D:\ORADATA\BOSCHDB\USERS01.DBF - dbid changed
Datafile D:\ORADATA\BOSCHDB\EXAMPLE01.DBF - dbid changed
Datafile D:\ORADATA\BOSCHDB\USER123.DBF - dbid changed
Control File D:\ORADATA\BOSCHDB\CONTROL01.CTL - dbid changed
Control File D:\ORADATA\BOSCHDB\CONTROL02.CTL - dbid changed
Control File D:\ORADATA\BOSCHDB\CONTROL03.CTL - dbid changed
Instance shut down
Database ID for database TESTDB changed to 2526615742.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
As you see in the above output database ID is changed from 1762398852 to 2526615742
Note 3: command for changing only Database name is given below:
nid TARGET=SYSTEM/manager@TESTDB DBNAME=TESTDB2 SETNAME=YES LOGFILE=dbname.out
Step 5: Open the Database and Verify.
------
After running the nid command(DBNEWID) utility Database will be shutdown
so open the database and open it with RESETLOGS option as it is described in the output of step4 and verify the Changed Database id with the help of v$database view.
SQL> startup mount
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1248600 bytes
Variable Size 96469672 bytes
Database Buffers 188743680 bytes
Redo Buffers 2945024 bytes
Database mounted.
SQL> alter database open resetlogs;
Database altered.
SQL> select dbid||' '||name||' '||resetlogs_change#||' '||resetlogs_time
2 from v$database;
DBID||''||NAME||''||RESETLOGS_CHANGE#||''||RESETLOGS_TIME
-------------------------------------------------------------------------------
2526615742 TESTDB 2702513 16-FEB 2011.
Some times small things matters the most.Hope it helps.
Best regards,
Rafi.
Database diagnosis script
Many times we are asked to check various things like what was the size of the database 2 years back,How are database is performing,How many processes are running,High Water Mark Statistics,Initialization Parameters description,controlfile,online redolog files status,Tablespaces sizes,Datafile sizes actualled used and various other things which is really happening your database so I founded one stop solution for this in the form of my Database diagnosis report.
Note 1:This script should be ran as sys user as sysdba privilege as follows.
Note 2:This process can take several minutes to complete depending on size and load on your database so wait for some time for it to complete.
Note 3: This script is very big,If you want the entire script separately mail me.
or else you can run this script by making parts Eg:Undo related,High water mark related as per your convenient
-- +----------------------------------------------------------------------------+
-- | /******* Rafi Oracle DBA & Apps DBA Blog *******\ |
-- | http://rafioracledba.blogspot.com/ |
-- | Database diagnosis report |
-- |----------------------------------------------------------------------------|
-- | |
-- |----------------------------------------------------------------------------|
-- | DATABASE : Oracle |
-- | FILE : dba_snapshot_database_10g.sql |
-- | CLASS : Database Administration |
-- | PURPOSE : This SQL script provides a detailed report (in HTML format) on |
-- | all database metrics including installed options, storage, |
-- | performance data, and security. |
-- | VERSION : This script was designed for Oracle Database 10g Release 2. |
-- | Although this script will also work with Oracle Database 10g |
-- | Release 1, several sections will error out from missing tables |
-- | or columns. |
-- | USAGE : |
-- | |
-- | sqlplus -s
-- | |
-- | TESTING : This script has been successfully tested on the following |
-- | platforms: |
-- | |
-- | Linux : Oracle Database 10.2.0.3.0 |
-- | Linux : Oracle RAC 10.2.0.3.0 |
-- | Solaris : Oracle Database 10.2.0.2.0 |
-- | Solaris : Oracle Database 10.2.0.3.0 |
-- | Windows XP : Oracle Database 10.2.0.3.0 |
-- | |
-- | NOTE : As with any code, ensure to test this script in a development |
-- | environment before attempting to run it in production. |
-- +----------------------------------------------------------------------------+
prompt
prompt +-----------------------------------------------------------------------------------------+
prompt | Snapshot Database 10g Release 2 |
prompt |-----------------------------------------------------------------------------------------+
prompt | ******* http://rafioracledba.blogspot.com ******* |
prompt +-----------------------------------------------------------------------------------------+
prompt
prompt Creating database report.
prompt This script must be run as a user with SYSDBA privileges.
prompt This process can take several minutes to complete.
prompt
define reportHeader="Snapshot Database 10g Release 2
******* http://rafioracledba.blogspot.com *******)
"
-- +----------------------------------------------------------------------------+
-- | SCRIPT SETTINGS |
-- +----------------------------------------------------------------------------+
set termout off
set echo off
set feedback off
set heading off
set verify off
set wrap on
set trimspool on
set serveroutput on
set escape on
set pagesize 50000
set linesize 175
set long 2000000000
clear buffer computes columns breaks
define fileName=dba_snapshot_database_10g
define versionNumber=5.3
-- +----------------------------------------------------------------------------+
-- | GATHER DATABASE REPORT INFORMATION |
-- +----------------------------------------------------------------------------+
COLUMN tdate NEW_VALUE _date NOPRINT
SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY') tdate FROM dual;
COLUMN time NEW_VALUE _time NOPRINT
SELECT TO_CHAR(SYSDATE,'HH24:MI:SS') time FROM dual;
COLUMN date_time NEW_VALUE _date_time NOPRINT
SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') date_time FROM dual;
COLUMN date_time_timezone NEW_VALUE _date_time_timezone NOPRINT
SELECT TO_CHAR(systimestamp, 'Mon DD, YYYY (') || TRIM(TO_CHAR(systimestamp, 'Day')) || TO_CHAR(systimestamp, ') "at" HH:MI:SS AM') || TO_CHAR(systimestamp, ' "in Timezone" TZR') date_time_timezone
FROM dual;
COLUMN spool_time NEW_VALUE _spool_time NOPRINT
SELECT TO_CHAR(SYSDATE,'YYYYMMDD') spool_time FROM dual;
COLUMN dbname NEW_VALUE _dbname NOPRINT
SELECT name dbname FROM v$database;
COLUMN dbid NEW_VALUE _dbid NOPRINT
SELECT dbid dbid FROM v$database;
COLUMN platform_id NEW_VALUE _platform_id NOPRINT
SELECT platform_id platform_id FROM v$database;
COLUMN platform_name NEW_VALUE _platform_name NOPRINT
SELECT platform_name platform_name FROM v$database;
COLUMN global_name NEW_VALUE _global_name NOPRINT
SELECT global_name global_name FROM global_name;
COLUMN blocksize NEW_VALUE _blocksize NOPRINT
SELECT value blocksize FROM v$parameter WHERE name='db_block_size';
COLUMN startup_time NEW_VALUE _startup_time NOPRINT
SELECT TO_CHAR(startup_time, 'MM/DD/YYYY HH24:MI:SS') startup_time FROM v$instance;
COLUMN host_name NEW_VALUE _host_name NOPRINT
SELECT host_name host_name FROM v$instance;
COLUMN instance_name NEW_VALUE _instance_name NOPRINT
SELECT instance_name instance_name FROM v$instance;
COLUMN instance_number NEW_VALUE _instance_number NOPRINT
SELECT instance_number instance_number FROM v$instance;
COLUMN thread_number NEW_VALUE _thread_number NOPRINT
SELECT thread# thread_number FROM v$instance;
COLUMN cluster_database NEW_VALUE _cluster_database NOPRINT
SELECT value cluster_database FROM v$parameter WHERE name='cluster_database';
COLUMN cluster_database_instances NEW_VALUE _cluster_database_instances NOPRINT
SELECT value cluster_database_instances FROM v$parameter WHERE name='cluster_database_instances';
COLUMN reportRunUser NEW_VALUE _reportRunUser NOPRINT
SELECT user reportRunUser FROM dual;
-- +----------------------------------------------------------------------------+
-- | GATHER DATABASE REPORT INFORMATION |
-- +----------------------------------------------------------------------------+
set heading on
set markup html on spool on preformat off entmap on -
head ' -
' -
body 'BGCOLOR="#C0C0C0"' -
table 'WIDTH="90%" BORDER="1"'
spool c:\&FileName._&_dbname._&_spool_time..html
set markup html on entmap off
-- +----------------------------------------------------------------------------+
-- | - REPORT HEADER - |
-- +----------------------------------------------------------------------------+
prompt
prompt &reportHeader
-- +----------------------------------------------------------------------------+
-- | - REPORT INDEX - |
-- +----------------------------------------------------------------------------+
prompt
prompt
prompt
-- +============================================================================+
-- | |
-- | <<<<< Database and Instance Information >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - REPORT HEADER - |
-- +----------------------------------------------------------------------------+
prompt
prompt
prompt Report Header
prompt
Report Name | &FileName._&_dbname._&_spool_time..html |
---|---|
Snapshot Database Version | &versionNumber |
Run Date / Time / Timezone | &_date_time_timezone |
Host Name | &_host_name |
Database Name | &_dbname |
Database ID | &_dbid |
Global Database Name | &_global_name |
Platform Name / ID | &_platform_name / &_platform_id |
Clustered Database? | &_cluster_database |
Clustered Database Instances | &_cluster_database_instances |
Instance Name | &_instance_name |
Instance Number | &_instance_number |
Thread Number | &_thread_number |
Database Startup Time | &_startup_time |
Database Block Size | &_blocksize |
Report Run User | &_reportRunUser |
prompt
-- SET TIMING ON
-- +----------------------------------------------------------------------------+
-- | - VERSION - |
-- +----------------------------------------------------------------------------+
prompt
prompt Version
CLEAR COLUMNS BREAKS COMPUTES
COLUMN banner FORMAT a120 HEADING 'Banner'
SELECT * FROM v$version;
prompt
-- +----------------------------------------------------------------------------+
-- | - OPTIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Options
CLEAR COLUMNS BREAKS COMPUTES
COLUMN parameter HEADING 'Option Name' ENTMAP off
COLUMN value HEADING 'Installed?' ENTMAP off
SELECT
DECODE( value
, 'FALSE'
, '' || parameter || ''
, '' || parameter || '') parameter
, DECODE( value
, 'FALSE'
, '
, '
FROM v$option
ORDER BY parameter;
prompt
-- +----------------------------------------------------------------------------+
-- | - DATABASE REGISTRY - |
-- +----------------------------------------------------------------------------+
prompt
prompt Database Registry
CLEAR COLUMNS BREAKS COMPUTES
COLUMN comp_id FORMAT a75 HEADING 'Component ID' ENTMAP off
COLUMN comp_name FORMAT a75 HEADING 'Component Name' ENTMAP off
COLUMN version HEADING 'Version' ENTMAP off
COLUMN status FORMAT a75 HEADING 'Status' ENTMAP off
COLUMN modified FORMAT a75 HEADING 'Modified' ENTMAP off
COLUMN control HEADING 'Control' ENTMAP off
COLUMN schema HEADING 'Schema' ENTMAP off
COLUMN procedure HEADING 'Procedure' ENTMAP off
SELECT
'' || comp_id || '' comp_id
, '
, version
, DECODE( status
, 'VALID', '
, 'INVALID', '
, '
, '
, control
, schema
, procedure
FROM dba_registry
ORDER BY comp_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - FEATURE USAGE STATISTICS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Feature Usage Statistics
CLEAR COLUMNS BREAKS COMPUTES
COLUMN feature_name FORMAT a115 HEADING 'Feature|Name'
COLUMN version FORMAT a75 HEADING 'Version'
COLUMN detected_usages FORMAT a75 HEADING 'Detected|Usages'
COLUMN total_samples FORMAT a75 HEADING 'Total|Samples'
COLUMN currently_used FORMAT a60 HEADING 'Currently|Used'
COLUMN first_usage_date FORMAT a95 HEADING 'First Usage|Date'
COLUMN last_usage_date FORMAT a95 HEADING 'Last Usage|Date'
COLUMN last_sample_date FORMAT a95 HEADING 'Last Sample|Date'
COLUMN next_sample_date FORMAT a95 HEADING 'Next Sample|Date'
SELECT
'
, DECODE( detected_usages
, 0
, version
, '' || version || '') version
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
, DECODE( detected_usages
, 0
, '
') || '
, '
') || '
FROM dba_feature_usage_statistics
ORDER BY name;
prompt
-- +----------------------------------------------------------------------------+
-- | - HIGH WATER MARK STATISTICS - |
-- +----------------------------------------------------------------------------+
prompt
prompt High Water Mark Statistics
CLEAR COLUMNS BREAKS COMPUTES
COLUMN statistic_name FORMAT a115 HEADING 'Statistic Name'
COLUMN version FORMAT a62 HEADING 'Version'
COLUMN highwater FORMAT 9,999,999,999,999,999 HEADING 'Highwater'
COLUMN last_value FORMAT 9,999,999,999,999,999 HEADING 'Last Value'
COLUMN description FORMAT a120 HEADING 'Description'
SELECT
'
, '
, highwater highwater
, last_value last_value
, description description
FROM dba_high_water_mark_statistics
ORDER BY name;
prompt
-- +----------------------------------------------------------------------------+
-- | - INSTANCE OVERVIEW - |
-- +----------------------------------------------------------------------------+
prompt
prompt Instance Overview
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a75 HEADING 'Instance|Name' ENTMAP off
COLUMN instance_number_print FORMAT a75 HEADING 'Instance|Num' ENTMAP off
COLUMN thread_number_print HEADING 'Thread|Num' ENTMAP off
COLUMN host_name_print FORMAT a75 HEADING 'Host|Name' ENTMAP off
COLUMN version HEADING 'Oracle|Version' ENTMAP off
COLUMN start_time FORMAT a75 HEADING 'Start|Time' ENTMAP off
COLUMN uptime HEADING 'Uptime|(in days)' ENTMAP off
COLUMN parallel FORMAT a75 HEADING 'Parallel - (RAC)' ENTMAP off
COLUMN instance_status FORMAT a75 HEADING 'Instance|Status' ENTMAP off
COLUMN database_status FORMAT a75 HEADING 'Database|Status' ENTMAP off
COLUMN logins FORMAT a75 HEADING 'Logins' ENTMAP off
COLUMN archiver FORMAT a75 HEADING 'Archiver' ENTMAP off
SELECT
'
, '
, '
, '
, '
, '
, ROUND(TO_CHAR(SYSDATE-startup_time), 2) uptime
, '
, '
, '
, DECODE( archiver
, 'FAILED'
, '
, '
FROM gv$instance
ORDER BY instance_number;
prompt
-- +----------------------------------------------------------------------------+
-- | - DATABASE OVERVIEW - |
-- +----------------------------------------------------------------------------+
prompt
prompt Database Overview
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name FORMAT a75 HEADING 'Database|Name' ENTMAP off
COLUMN dbid HEADING 'Database|ID' ENTMAP off
COLUMN db_unique_name HEADING 'Database|Unique Name' ENTMAP off
COLUMN creation_date HEADING 'Creation|Date' ENTMAP off
COLUMN platform_name_print HEADING 'Platform|Name' ENTMAP off
COLUMN current_scn HEADING 'Current|SCN' ENTMAP off
COLUMN log_mode HEADING 'Log|Mode' ENTMAP off
COLUMN open_mode HEADING 'Open|Mode' ENTMAP off
COLUMN force_logging HEADING 'Force|Logging' ENTMAP off
COLUMN flashback_on HEADING 'Flashback|On?' ENTMAP off
COLUMN controlfile_type HEADING 'Controlfile|Type' ENTMAP off
COLUMN last_open_incarnation_number HEADING 'Last Open|Incarnation Num' ENTMAP off
SELECT
'
, '
, '
, '
, '
, '
, '
, '
, '
, '
, '
, '
FROM v$database;
prompt
-- +----------------------------------------------------------------------------+
-- | - INITIALIZATION PARAMETERS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Initialization Parameters
CLEAR COLUMNS BREAKS COMPUTES
COLUMN spfile HEADING 'SPFILE Usage'
SELECT
'This database '||
DECODE( (1-SIGN(1-SIGN(count(*) - 0)))
, 1
, 'IS'
, 'IS NOT') ||
' using an SPFILE.'spfile
FROM v$spparameter
WHERE value IS NOT null;
COLUMN pname FORMAT a75 HEADING 'Parameter Name' ENTMAP off
COLUMN instance_name_print FORMAT a45 HEADING 'Instance Name' ENTMAP off
COLUMN value FORMAT a75 HEADING 'Value' ENTMAP off
COLUMN isdefault FORMAT a75 HEADING 'Is Default?' ENTMAP off
COLUMN issys_modifiable FORMAT a75 HEADING 'Is Dynamic?' ENTMAP off
BREAK ON report ON pname
SELECT
DECODE( p.isdefault
, 'FALSE'
, '' || SUBSTR(p.name,0,512) || ''
, '' || SUBSTR(p.name,0,512) || '' ) pname
, DECODE( p.isdefault
, 'FALSE'
, '' || i.instance_name || ''
, i.instance_name ) instance_name_print
, DECODE( p.isdefault
, 'FALSE'
, '' || SUBSTR(p.value,0,512) || ''
, SUBSTR(p.value,0,512) ) value
, DECODE( p.isdefault
, 'FALSE'
, '
, '
, DECODE( p.isdefault
, 'FALSE'
, '
, '
FROM
gv$parameter p
, gv$instance i
WHERE
p.inst_id = i.inst_id
ORDER BY
p.name
, i.instance_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - CONTROL FILES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Control Files
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name HEADING 'Controlfile Name' ENTMAP off
COLUMN status FORMAT a75 HEADING 'Status' ENTMAP off
COLUMN file_size FORMAT a75 HEADING 'File Size' ENTMAP off
SELECT
'' || c.name || '' name
, DECODE( c.status
, NULL
, '
, '
, '
FROM
v$controlfile c
ORDER BY
c.name;
prompt
-- +----------------------------------------------------------------------------+
-- | - CONTROL FILE RECORDS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Control File Records
CLEAR COLUMNS BREAKS COMPUTES
COLUMN type FORMAT a95 HEADING 'Record Section Type' ENTMAP off
COLUMN record_size FORMAT 999,999 HEADING 'Record Size|(in bytes)' ENTMAP off
COLUMN records_total FORMAT 999,999 HEADING 'Records Allocated' ENTMAP off
COLUMN bytes_alloc FORMAT 999,999,999 HEADING 'Bytes Allocated' ENTMAP off
COLUMN records_used FORMAT 999,999 HEADING 'Records Used' ENTMAP off
COLUMN bytes_used FORMAT 999,999,999 HEADING 'Bytes Used' ENTMAP off
COLUMN pct_used FORMAT B999 HEADING '% Used' ENTMAP off
COLUMN first_index HEADING 'First Index' ENTMAP off
COLUMN last_index HEADING 'Last Index' ENTMAP off
COLUMN last_recid HEADING 'Last RecID' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total: ' of record_size records_total bytes_alloc records_used bytes_used ON report
COMPUTE avg LABEL 'Average: ' of pct_used ON report
SELECT
'
, record_size record_size
, records_total records_total
, (records_total * record_size) bytes_alloc
, records_used records_used
, (records_used * record_size) bytes_used
, NVL(records_used/records_total * 100, 0) pct_used
, first_index first_index
, last_index last_index
, last_recid last_recid
FROM v$controlfile_record_section
ORDER BY type;
prompt
-- +----------------------------------------------------------------------------+
-- | - ONLINE REDO LOGS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Online Redo Logs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a95 HEADING 'Instance Name' ENTMAP off
COLUMN thread_number_print FORMAT a95 HEADING 'Thread Number' ENTMAP off
COLUMN groupno HEADING 'Group Number' ENTMAP off
COLUMN member HEADING 'Member' ENTMAP off
COLUMN redo_file_type FORMAT a75 HEADING 'Redo Type' ENTMAP off
COLUMN log_status FORMAT a75 HEADING 'Log Status' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999 HEADING 'Bytes' ENTMAP off
COLUMN archived FORMAT a75 HEADING 'Archived?' ENTMAP off
BREAK ON report ON instance_name_print ON thread_number_print
SELECT
'
, '
, f.group# groupno
, '' || f.member || '' member
, f.type redo_file_type
, DECODE( l.status
, 'CURRENT'
, '
, '
, l.bytes bytes
, '
FROM
gv$logfile f
, gv$log l
, gv$instance i
WHERE
f.group# = l.group#
AND l.thread# = i.thread#
AND i.inst_id = f.inst_id
AND f.inst_id = l.inst_id
ORDER BY
i.instance_name
, f.group#
, f.member;
prompt
-- +----------------------------------------------------------------------------+
-- | - REDO LOG SWITCHES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Redo Log Switches
CLEAR COLUMNS BREAKS COMPUTES
COLUMN DAY FORMAT a75 HEADING 'Day / Time' ENTMAP off
COLUMN H00 FORMAT 999,999B HEADING '00' ENTMAP off
COLUMN H01 FORMAT 999,999B HEADING '01' ENTMAP off
COLUMN H02 FORMAT 999,999B HEADING '02' ENTMAP off
COLUMN H03 FORMAT 999,999B HEADING '03' ENTMAP off
COLUMN H04 FORMAT 999,999B HEADING '04' ENTMAP off
COLUMN H05 FORMAT 999,999B HEADING '05' ENTMAP off
COLUMN H06 FORMAT 999,999B HEADING '06' ENTMAP off
COLUMN H07 FORMAT 999,999B HEADING '07' ENTMAP off
COLUMN H08 FORMAT 999,999B HEADING '08' ENTMAP off
COLUMN H09 FORMAT 999,999B HEADING '09' ENTMAP off
COLUMN H10 FORMAT 999,999B HEADING '10' ENTMAP off
COLUMN H11 FORMAT 999,999B HEADING '11' ENTMAP off
COLUMN H12 FORMAT 999,999B HEADING '12' ENTMAP off
COLUMN H13 FORMAT 999,999B HEADING '13' ENTMAP off
COLUMN H14 FORMAT 999,999B HEADING '14' ENTMAP off
COLUMN H15 FORMAT 999,999B HEADING '15' ENTMAP off
COLUMN H16 FORMAT 999,999B HEADING '16' ENTMAP off
COLUMN H17 FORMAT 999,999B HEADING '17' ENTMAP off
COLUMN H18 FORMAT 999,999B HEADING '18' ENTMAP off
COLUMN H19 FORMAT 999,999B HEADING '19' ENTMAP off
COLUMN H20 FORMAT 999,999B HEADING '20' ENTMAP off
COLUMN H21 FORMAT 999,999B HEADING '21' ENTMAP off
COLUMN H22 FORMAT 999,999B HEADING '22' ENTMAP off
COLUMN H23 FORMAT 999,999B HEADING '23' ENTMAP off
COLUMN TOTAL FORMAT 999,999,999 HEADING 'Total' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total:' avg label 'Average:' OF total ON report
SELECT
'
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'00',1,0)) H00
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'01',1,0)) H01
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'02',1,0)) H02
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'03',1,0)) H03
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'04',1,0)) H04
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'05',1,0)) H05
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'06',1,0)) H06
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'07',1,0)) H07
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'08',1,0)) H08
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'09',1,0)) H09
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'10',1,0)) H10
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'11',1,0)) H11
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'12',1,0)) H12
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'13',1,0)) H13
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'14',1,0)) H14
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'15',1,0)) H15
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'16',1,0)) H16
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'17',1,0)) H17
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'18',1,0)) H18
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'19',1,0)) H19
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'20',1,0)) H20
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'21',1,0)) H21
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'22',1,0)) H22
, SUM(DECODE(SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH24:MI:SS'),10,2),'23',1,0)) H23
, COUNT(*) TOTAL
FROM
v$log_history a
GROUP BY SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH:MI:SS'),1,5)
ORDER BY SUBSTR(TO_CHAR(first_time, 'MM/DD/RR HH:MI:SS'),1,5)
/
prompt
-- +----------------------------------------------------------------------------+
-- | - OUTSTANDING ALERTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Outstanding Alerts
CLEAR COLUMNS BREAKS COMPUTES
COLUMN severity FORMAT a75 HEADING 'Severity' ENTMAP off
COLUMN target_name FORMAT a75 HEADING 'Target Name' ENTMAP off
COLUMN target_type FORMAT a75 HEADING 'Target Type' ENTMAP off
COLUMN category FORMAT a75 HEADING 'Category' ENTMAP off
COLUMN name FORMAT a75 HEADING 'Name' ENTMAP off
COLUMN message FORMAT a125 HEADING 'Message' ENTMAP off
COLUMN alert_triggered FORMAT a75 HEADING 'Alert Triggered' ENTMAP off
SELECT
DECODE( alert_state
, 'Critical'
, '
, '
, target_name target_name
, (CASE target_type
WHEN 'oracle_listener' THEN 'Oracle Listener'
WHEN 'rac_database' THEN 'Cluster Database'
WHEN 'cluster' THEN 'Clusterware'
WHEN 'host' THEN 'Host'
WHEN 'osm_instance' THEN 'OSM Instance'
WHEN 'oracle_database' THEN 'Database Instance'
WHEN 'oracle_emd' THEN 'Oracle EMD'
WHEN 'oracle_emrep' THEN 'Oracle EMREP'
ELSE
target_type
END) target_type
, metric_label category
, column_label name
, message message
, '
FROM
mgmt$alert_current
ORDER BY
alert_state
, collection_timestamp;
prompt
-- +----------------------------------------------------------------------------+
-- | - STATISTICS LEVEL - |
-- +----------------------------------------------------------------------------+
prompt
prompt Statistics Level
prompt "Automatic Database Management" was first introduced in Oracle10g where the Oracle database
prompt can now automatically perform many of the routine monitoring and administrative activities that had
prompt to be manually executed by the DBA in previous versions. Several of the new components that make
prompt up this new feature include (1) Automatic Workload Repository (2) Automatic Database Diagnostic
prompt Monitoring (3) Automatic Shared Memory Management and (4) Automatic UNDO Retention Tuning. All
prompt of these new components can only be enabled when the STATISTICS_LEVEL initialization parameter
prompt is set to TYPICAL (the default) or ALL. A value of BASIC turns off these components and disables
prompt all self-tuning capabilities of the database. The view V$STATISTICS_LEVEL shows the statistic
prompt component, description, and at what level of the STATISTICS_LEVEL parameter the
prompt component is enabled.
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a95 HEADING 'Instance Name' ENTMAP off
COLUMN statistics_name FORMAT a95 HEADING 'Statistics Name' ENTMAP off
COLUMN session_status FORMAT a95 HEADING 'Session Status' ENTMAP off
COLUMN system_status FORMAT a95 HEADING 'System Status' ENTMAP off
COLUMN activation_level FORMAT a95 HEADING 'Activation Level' ENTMAP off
COLUMN statistics_view_name FORMAT a95 HEADING 'Statistics View Name' ENTMAP off
COLUMN session_settable FORMAT a95 HEADING 'Session Settable?' ENTMAP off
BREAK ON report ON instance_name_print
SELECT
'
, '
, DECODE( s.session_status
, 'ENABLED'
, '
, '
, DECODE( s.system_status
, 'ENABLED'
, '
, '
, (CASE s.activation_level
WHEN 'TYPICAL' THEN '
WHEN 'ALL' THEN '
WHEN 'BASIC' THEN '
ELSE
'
END) activation_level
, s.statistics_view_name statistics_view_name
, '
FROM
gv$statistics_level s
, gv$instance i
WHERE
s.inst_id = i.inst_id
ORDER BY
i.instance_name
, s.statistics_name;
prompt
-- +============================================================================+
-- | |
-- | <<<<< SCHEDULER / JOBS >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN job_id FORMAT a75 HEADING 'Job ID' ENTMAP off
COLUMN username FORMAT a75 HEADING 'User' ENTMAP off
COLUMN what FORMAT a175 HEADING 'What' ENTMAP off
COLUMN next_date FORMAT a110 HEADING 'Next Run Date' ENTMAP off
COLUMN interval FORMAT a75 HEADING 'Interval' ENTMAP off
COLUMN last_date FORMAT a110 HEADING 'Last Run Date' ENTMAP off
COLUMN failures FORMAT a75 HEADING 'Failures' ENTMAP off
COLUMN broken FORMAT a75 HEADING 'Broken?' ENTMAP off
SELECT
DECODE( broken
, 'Y'
, '
, '
, DECODE( broken
, 'Y'
, '' || log_user || ''
, log_user ) username
, DECODE( broken
, 'Y'
, '' || what || ''
, what ) what
, DECODE( broken
, 'Y'
, '
') || '
, '
') || '
, DECODE( broken
, 'Y'
, '' || interval || ''
, interval ) interval
, DECODE( broken
, 'Y'
, '
') || '
, '
') || '
, DECODE( broken
, 'Y'
, '
, '
, DECODE( broken
, 'Y'
, '
, '
FROM
dba_jobs
ORDER BY
job;
prompt
-- +============================================================================+
-- | |
-- | <<<<< STORAGE >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - TABLESPACES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Tablespaces
CLEAR COLUMNS BREAKS COMPUTES
COLUMN status HEADING 'Status' ENTMAP off
COLUMN name HEADING 'Tablespace Name' ENTMAP off
COLUMN type FORMAT a12 HEADING 'TS Type' ENTMAP off
COLUMN extent_mgt FORMAT a10 HEADING 'Ext. Mgt.' ENTMAP off
COLUMN segment_mgt FORMAT a9 HEADING 'Seg. Mgt.' ENTMAP off
COLUMN ts_size FORMAT 999,999,999,999,999 HEADING 'Tablespace Size' ENTMAP off
COLUMN free FORMAT 999,999,999,999,999 HEADING 'Free (in bytes)' ENTMAP off
COLUMN used FORMAT 999,999,999,999,999 HEADING 'Used (in bytes)' ENTMAP off
COLUMN pct_used HEADING 'Pct. Used' ENTMAP off
BREAK ON report
COMPUTE SUM label 'Total:' OF ts_size used free ON report
SELECT
DECODE( d.status
, 'OFFLINE'
, '
, '
, '' || d.tablespace_name || '' name
, d.contents type
, d.extent_management extent_mgt
, d.segment_space_management segment_mgt
, NVL(a.bytes, 0) ts_size
, NVL(f.bytes, 0) free
, NVL(a.bytes - NVL(f.bytes, 0), 0) used
, '
DECODE (
(1-SIGN(1-SIGN(TRUNC(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0)) - 90)))
, 1
, '' || TO_CHAR(TRUNC(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0))) || ''
, '' || TO_CHAR(TRUNC(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0))) || ''
)
|| ' %
FROM
sys.dba_tablespaces d
, ( select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name
) a
, ( select tablespace_name, sum(bytes) bytes
from dba_free_space
group by tablespace_name
) f
WHERE
d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = f.tablespace_name(+)
AND NOT (
d.extent_management like 'LOCAL'
AND
d.contents like 'TEMPORARY'
)
UNION ALL
SELECT
DECODE( d.status
, 'OFFLINE'
, '
, '
, '' || d.tablespace_name || '' name
, d.contents type
, d.extent_management extent_mgt
, d.segment_space_management segment_mgt
, NVL(a.bytes, 0) ts_size
, NVL(a.bytes - NVL(t.bytes,0), 0) free
, NVL(t.bytes, 0) used
, '
DECODE (
(1-SIGN(1-SIGN(TRUNC(NVL(t.bytes / a.bytes * 100, 0)) - 90)))
, 1
, '' || TO_CHAR(TRUNC(NVL(t.bytes / a.bytes * 100, 0))) || ''
, '' || TO_CHAR(TRUNC(NVL(t.bytes / a.bytes * 100, 0))) || ''
)
|| ' %
FROM
sys.dba_tablespaces d
, ( select tablespace_name, sum(bytes) bytes
from dba_temp_files
group by tablespace_name
) a
, ( select tablespace_name, sum(bytes_cached) bytes
from v$temp_extent_pool
group by tablespace_name
) t
WHERE
d.tablespace_name = a.tablespace_name(+)
AND d.tablespace_name = t.tablespace_name(+)
AND d.extent_management like 'LOCAL'
AND d.contents like 'TEMPORARY'
ORDER BY 2;
prompt
-- +----------------------------------------------------------------------------+
-- | - DATA FILES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Data Files
CLEAR COLUMNS BREAKS COMPUTES
COLUMN tablespace HEADING 'Tablespace Name / File Class' ENTMAP off
COLUMN filename HEADING 'Filename' ENTMAP off
COLUMN filesize FORMAT 999,999,999,999,999 HEADING 'File Size' ENTMAP off
COLUMN autoextensible HEADING 'Autoextensible' ENTMAP off
COLUMN increment_by FORMAT 999,999,999,999,999 HEADING 'Next' ENTMAP off
COLUMN maxbytes FORMAT 999,999,999,999,999 HEADING 'Max' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total: ' OF filesize ON report
SELECT /*+ ordered */
'' || d.tablespace_name || '' tablespace
, '' || d.file_name || '' filename
, d.bytes filesize
, '
') || '
, d.increment_by * e.value increment_by
, d.maxbytes maxbytes
FROM
sys.dba_data_files d
, v$datafile v
, (SELECT value
FROM v$parameter
WHERE name = 'db_block_size') e
WHERE
(d.file_name = v.name)
UNION
SELECT
'' || d.tablespace_name || '' tablespace
, '' || d.file_name || '' filename
, d.bytes filesize
, '
') || '
, d.increment_by * e.value increment_by
, d.maxbytes maxbytes
FROM
sys.dba_temp_files d
, (SELECT value
FROM v$parameter
WHERE name = 'db_block_size') e
UNION
SELECT
'[ ONLINE REDO LOG ]'
, '' || a.member || ''
, b.bytes
, null
, null
, null
FROM
v$logfile a
, v$log b
WHERE
a.group# = b.group#
UNION
SELECT
'[ CONTROL FILE ]'
, '' || a.name || ''
, null
, null
, null
, null
FROM
v$controlfile a
ORDER BY
1
, 2;
prompt
-- +----------------------------------------------------------------------------+
-- | - DATABASE GROWTH - |
-- +----------------------------------------------------------------------------+
prompt
prompt Database Growth
CLEAR COLUMNS BREAKS COMPUTES
COLUMN month FORMAT a75 HEADING 'Month'
COLUMN growth FORMAT 999,999,999,999,999 HEADING 'Growth (bytes)'
BREAK ON report
COMPUTE SUM label 'Total:' OF growth ON report
SELECT
'
, SUM(bytes) growth
FROM sys.v_$datafile
GROUP BY TO_CHAR(creation_time, 'RRRR-MM')
ORDER BY TO_CHAR(creation_time, 'RRRR-MM');
prompt
-- +----------------------------------------------------------------------------+
-- | - TABLESPACE EXTENTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Tablespace Extents
CLEAR COLUMNS BREAKS COMPUTES
COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP off
COLUMN largest_ext FORMAT 999,999,999,999,999 HEADING 'Largest Extent' ENTMAP off
COLUMN smallest_ext FORMAT 999,999,999,999,999 HEADING 'Smallest Extent' ENTMAP off
COLUMN total_free FORMAT 999,999,999,999,999 HEADING 'Total Free' ENTMAP off
COLUMN pieces FORMAT 999,999,999,999,999 HEADING 'Number of Free Extents' ENTMAP off
break on report
compute sum label 'Total:' of largest_ext smallest_ext total_free pieces on report
SELECT
'' || tablespace_name || '' tablespace_name
, max(bytes) largest_ext
, min(bytes) smallest_ext
, sum(bytes) total_free
, count(*) pieces
FROM
dba_free_space
GROUP BY
tablespace_name
ORDER BY
tablespace_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - TABLESPACE TO OWNER - |
-- +----------------------------------------------------------------------------+
prompt
prompt Tablespace to Owner
CLEAR COLUMNS BREAKS COMPUTES
COLUMN tablespace_name FORMAT a75 HEADING 'Tablespace Name' ENTMAP off
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN segment_type FORMAT a75 HEADING 'Segment Type' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in Bytes)' ENTMAP off
COLUMN seg_count FORMAT 999,999,999,999 HEADING 'Segment Count' ENTMAP off
BREAK ON report ON tablespace_name
COMPUTE sum LABEL 'Total: ' of seg_count bytes ON report
SELECT
'' || tablespace_name || '' tablespace_name
, '
, '
, sum(bytes) bytes
, count(*) seg_count
FROM
dba_segments
GROUP BY
tablespace_name
, owner
, segment_type
ORDER BY
tablespace_name
, owner
, segment_type;
prompt
-- +----------------------------------------------------------------------------+
-- | - OWNER TO TABLESPACE - |
-- +----------------------------------------------------------------------------+
prompt
prompt Owner to Tablespace
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN tablespace_name FORMAT a75 HEADING 'Tablespace Name' ENTMAP off
COLUMN segment_type FORMAT a75 HEADING 'Segment Type' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in Bytes)' ENTMAP off
COLUMN seg_count FORMAT 999,999,999,999 HEADING 'Segment Count' ENTMAP off
break on report on owner
compute sum label 'Total: ' of seg_count bytes on report
SELECT
'' || owner || '' owner
, '
, '
, sum(bytes) bytes
, count(*) seg_count
FROM
dba_segments
GROUP BY
owner
, tablespace_name
, segment_type
ORDER BY
owner
, tablespace_name
, segment_type;
prompt
-- +============================================================================+
-- | |
-- | <<<<< UNDO Segments >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - UNDO RETENTION PARAMETERS - |
-- +----------------------------------------------------------------------------+
prompt
prompt UNDO Retention Parameters
prompt undo_retention is specified in minutes
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a95 HEADING 'Instance Name' ENTMAP off
COLUMN thread_number_print FORMAT a95 HEADING 'Thread Number' ENTMAP off
COLUMN name FORMAT a125 HEADING 'Name' ENTMAP off
COLUMN value HEADING 'Value' ENTMAP off
BREAK ON report ON instance_name_print ON thread_number_print
SELECT
'
, '
, '
, (CASE p.name
WHEN 'undo_retention' THEN '
ELSE
'
END) value
FROM
gv$parameter p
, gv$instance i
WHERE
p.inst_id = i.inst_id
AND p.name LIKE 'undo%'
ORDER BY
i.instance_name
, p.name;
prompt
-- +----------------------------------------------------------------------------+
-- | - UNDO SEGMENTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt UNDO Segments
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a75 HEADING 'Instance Name' ENTMAP off
COLUMN tablespace FORMAT a85 HEADING 'Tablspace' ENTMAP off
COLUMN roll_name HEADING 'UNDO Segment Name' ENTMAP off
COLUMN in_extents HEADING 'Init/Next Extents' ENTMAP off
COLUMN m_extents HEADING 'Min/Max Extents' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN wraps FORMAT 999,999,999 HEADING 'Wraps' ENTMAP off
COLUMN shrinks FORMAT 999,999,999 HEADING 'Shrinks' ENTMAP off
COLUMN opt FORMAT 999,999,999,999 HEADING 'Opt. Size' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999 HEADING 'Bytes' ENTMAP off
COLUMN extents FORMAT 999,999,999 HEADING 'Extents' ENTMAP off
CLEAR COMPUTES BREAKS
BREAK ON report ON instance_name ON tablespace
-- COMPUTE sum LABEL 'Total:' OF bytes extents shrinks wraps ON report
SELECT
'
') || '
, '
, '
, '
TO_CHAR(a.initial_extent) || ' / ' ||
TO_CHAR(a.next_extent) ||
'
, '
TO_CHAR(a.min_extents) || ' / ' ||
TO_CHAR(a.max_extents) ||
'
, DECODE( a.status
, 'OFFLINE'
, '
, '
, b.bytes bytes
, b.extents extents
, d.shrinks shrinks
, d.wraps wraps
, d.optsize opt
FROM
dba_rollback_segs a
, dba_segments b
, v$rollname c
, v$rollstat d
, gv$parameter p
, gv$instance i
WHERE
a.segment_name = b.segment_name
AND a.segment_name = c.name (+)
AND c.usn = d.usn (+)
AND p.name (+) = 'undo_tablespace'
AND p.value (+) = a.tablespace_name
AND p.inst_id = i.inst_id (+)
ORDER BY
a.tablespace_name
, a.segment_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - UNDO SEGMENT CONTENTION - |
-- +----------------------------------------------------------------------------+
prompt
prompt UNDO Segment Contention
prompt UNDO statistics from V$ROLLSTAT - (ordered by waits)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN roll_name HEADING 'UNDO Segment Name' ENTMAP off
COLUMN gets FORMAT 999,999,999 HEADING 'Gets' ENTMAP off
COLUMN waits FORMAT 999,999,999 HEADING 'Waits' ENTMAP off
COLUMN immediate_misses FORMAT 999,999,999 HEADING 'Immediate Misses' ENTMAP off
COLUMN hit_ratio HEADING 'Hit Ratio' ENTMAP off
BREAK ON report
COMPUTE SUM label 'Total:' OF gets waits ON report
SELECT
'' || b.name || '' roll_name
, gets gets
, waits waits
, '
FROM
sys.v_$rollstat a
, sys.v_$rollname b
WHERE
a.USN = b.USN
ORDER BY
waits DESC;
prompt
prompt Wait statistics
CLEAR COLUMNS BREAKS COMPUTES
COLUMN class HEADING 'Class'
COLUMN ratio HEADING 'Wait Ratio'
SELECT
'' || w.class || '' class
, '
FROM
v$waitstat w
, v$sysstat s
WHERE
w.class IN ( 'system undo header'
, 'system undo block'
, 'undo header'
, 'undo block'
)
AND s.name IN ('db block gets', 'consistent gets')
GROUP BY
w.class
, w.count;
prompt
-- +============================================================================+
-- | |
-- | <<<<< BACKUPS >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - RMAN BACKUP JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt RMAN Backup Jobs
prompt Last 10 RMAN backup jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN backup_name FORMAT a130 HEADING 'Backup Name' ENTMAP off
COLUMN start_time FORMAT a75 HEADING 'Start Time' ENTMAP off
COLUMN elapsed_time FORMAT a75 HEADING 'Elapsed Time' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN input_type HEADING 'Input Type' ENTMAP off
COLUMN output_device_type HEADING 'Output Devices' ENTMAP off
COLUMN input_size HEADING 'Input Size' ENTMAP off
COLUMN output_size HEADING 'Output Size' ENTMAP off
COLUMN output_rate_per_sec HEADING 'Output Rate Per Sec' ENTMAP off
SELECT
'
, '
, '
, DECODE( r.status
, 'COMPLETED'
, '
, 'RUNNING'
, '
, 'FAILED'
, '
, '
) status
, r.input_type input_type
, r.output_device_type output_device_type
, '
, '
, '
FROM
(select
command_id
, start_time
, time_taken_display
, status
, input_type
, output_device_type
, input_bytes_display
, output_bytes_display
, output_bytes_per_sec_display
from v$rman_backup_job_details
order by start_time DESC
) r
WHERE
rownum < 11;
prompt
-- +----------------------------------------------------------------------------+
-- | - RMAN CONFIGURATION - |
-- +----------------------------------------------------------------------------+
prompt
prompt RMAN Configuration
prompt All non-default RMAN configuration settings
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name FORMAT a130 HEADING 'Name' ENTMAP off
COLUMN value HEADING 'Value' ENTMAP off
SELECT
'
, value
FROM
v$rman_configuration
ORDER BY
name;
prompt
-- +----------------------------------------------------------------------------+
-- | - RMAN BACKUP SETS - |
-- +----------------------------------------------------------------------------+
prompt
prompt RMAN Backup Sets
prompt Available backup sets contained in the control file including available and expired backup sets
CLEAR COLUMNS BREAKS COMPUTES
COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP off
COLUMN backup_type FORMAT a70 HEADING 'Backup Type' ENTMAP off
COLUMN device_type HEADING 'Device Type' ENTMAP off
COLUMN controlfile_included FORMAT a30 HEADING 'Controlfile Included?' ENTMAP off
COLUMN spfile_included FORMAT a30 HEADING 'SPFILE Included?' ENTMAP off
COLUMN incremental_level HEADING 'Incremental Level' ENTMAP off
COLUMN pieces FORMAT 999,999,999,999 HEADING '# of Pieces' ENTMAP off
COLUMN start_time FORMAT a75 HEADING 'Start Time' ENTMAP off
COLUMN completion_time FORMAT a75 HEADING 'End Time' ENTMAP off
COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP off
COLUMN tag HEADING 'Tag' ENTMAP off
COLUMN block_size FORMAT 999,999,999,999,999 HEADING 'Block Size' ENTMAP off
COLUMN keep FORMAT a40 HEADING 'Keep?' ENTMAP off
COLUMN keep_until FORMAT a75 HEADING 'Keep Until' ENTMAP off
COLUMN keep_options FORMAT a15 HEADING 'Keep Options' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total:' OF pieces elapsed_seconds ON report
SELECT
'
, DECODE(backup_type
, 'L', '
, 'D', '
, 'I', '
, '
, '
DECODE(bs.controlfile_included, 'NO', '-', bs.controlfile_included) || '
, '
, bs.incremental_level incremental_level
, bs.pieces pieces
, '
, '
, bs.elapsed_seconds elapsed_seconds
, bp.tag tag
, bs.block_size block_size
, '
, '
') || '
, bs.keep_options keep_options
FROM
v$backup_set bs
, (select distinct
set_stamp
, set_count
, tag
, device_type
from v$backup_piece
where status in ('A', 'X')) bp
, (select distinct set_stamp, set_count, 'YES' spfile_included
from v$backup_spfile) sp
WHERE
bs.set_stamp = bp.set_stamp
AND bs.set_count = bp.set_count
AND bs.set_stamp = sp.set_stamp (+)
AND bs.set_count = sp.set_count (+)
ORDER BY
bs.recid;
prompt
-- +----------------------------------------------------------------------------+
-- | - RMAN BACKUP PIECES - |
-- +----------------------------------------------------------------------------+
prompt
prompt RMAN Backup Pieces
prompt Available backup pieces contained in the control file including available and expired backup sets
CLEAR COLUMNS BREAKS COMPUTES
COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP off
COLUMN piece# HEADING 'Piece #' ENTMAP off
COLUMN copy# HEADING 'Copy #' ENTMAP off
COLUMN bp_key HEADING 'BP Key' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN handle HEADING 'Handle' ENTMAP off
COLUMN start_time FORMAT a75 HEADING 'Start Time' ENTMAP off
COLUMN completion_time FORMAT a75 HEADING 'End Time' ENTMAP off
COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP off
COLUMN deleted FORMAT a10 HEADING 'Deleted?' ENTMAP off
BREAK ON bs_key
SELECT
'
, bp.piece# piece#
, bp.copy# copy#
, bp.recid bp_key
, DECODE( status
, 'A', '
, 'D', '
, 'X', '
, handle handle
, '
, '
, bp.elapsed_seconds elapsed_seconds
FROM
v$backup_set bs
, v$backup_piece bp
WHERE
bs.set_stamp = bp.set_stamp
AND bs.set_count = bp.set_count
AND bp.status IN ('A', 'X')
ORDER BY
bs.recid
, piece#;
prompt
-- +----------------------------------------------------------------------------+
-- | - RMAN BACKUP CONTROL FILES - |
-- +----------------------------------------------------------------------------+
prompt
prompt RMAN Backup Control Files
prompt Available automatic control files within all available (and expired) backup sets
CLEAR COLUMNS BREAKS COMPUTES
COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP off
COLUMN piece# HEADING 'Piece #' ENTMAP off
COLUMN copy# HEADING 'Copy #' ENTMAP off
COLUMN bp_key HEADING 'BP Key' ENTMAP off
COLUMN controlfile_included FORMAT a75 HEADING 'Controlfile Included?' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN handle HEADING 'Handle' ENTMAP off
COLUMN start_time FORMAT a40 HEADING 'Start Time' ENTMAP off
COLUMN completion_time FORMAT a40 HEADING 'End Time' ENTMAP off
COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP off
COLUMN deleted FORMAT a10 HEADING 'Deleted?' ENTMAP off
BREAK ON bs_key
SELECT
'
, bp.piece# piece#
, bp.copy# copy#
, bp.recid bp_key
, '
DECODE(bs.controlfile_included, 'NO', '-', bs.controlfile_included) ||
'
, DECODE( status
, 'A', '
, 'D', '
, 'X', '
, handle handle
FROM
v$backup_set bs
, v$backup_piece bp
WHERE
bs.set_stamp = bp.set_stamp
AND bs.set_count = bp.set_count
AND bp.status IN ('A', 'X')
AND bs.controlfile_included != 'NO'
ORDER BY
bs.recid
, piece#;
prompt
-- +----------------------------------------------------------------------------+
-- | - RMAN BACKUP SPFILE - |
-- +----------------------------------------------------------------------------+
prompt
prompt RMAN Backup SPFILE
prompt Available automatic SPFILE backups within all available (and expired) backup sets
CLEAR COLUMNS BREAKS COMPUTES
COLUMN bs_key FORMAT a75 HEADING 'BS Key' ENTMAP off
COLUMN piece# HEADING 'Piece #' ENTMAP off
COLUMN copy# HEADING 'Copy #' ENTMAP off
COLUMN bp_key HEADING 'BP Key' ENTMAP off
COLUMN spfile_included FORMAT a75 HEADING 'SPFILE Included?' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN handle HEADING 'Handle' ENTMAP off
COLUMN start_time FORMAT a40 HEADING 'Start Time' ENTMAP off
COLUMN completion_time FORMAT a40 HEADING 'End Time' ENTMAP off
COLUMN elapsed_seconds FORMAT 999,999,999,999,999 HEADING 'Elapsed Seconds' ENTMAP off
COLUMN deleted FORMAT a10 HEADING 'Deleted?' ENTMAP off
BREAK ON bs_key
SELECT
'
, bp.piece# piece#
, bp.copy# copy#
, bp.recid bp_key
, '
NVL(sp.spfile_included, '-') ||
'
, DECODE( status
, 'A', '
, 'D', '
, 'X', '
, handle handle
FROM
v$backup_set bs
, v$backup_piece bp
, (select distinct set_stamp, set_count, 'YES' spfile_included
from v$backup_spfile) sp
WHERE
bs.set_stamp = bp.set_stamp
AND bs.set_count = bp.set_count
AND bp.status IN ('A', 'X')
AND bs.set_stamp = sp.set_stamp
AND bs.set_count = sp.set_count
ORDER BY
bs.recid
, piece#;
prompt
-- +----------------------------------------------------------------------------+
-- | - ARCHIVING MODE - |
-- +----------------------------------------------------------------------------+
prompt
prompt Archiving Mode
CLEAR COLUMNS BREAKS COMPUTES
COLUMN db_log_mode FORMAT a95 HEADING 'Database|Log Mode' ENTMAP off
COLUMN log_archive_start FORMAT a95 HEADING 'Automatic|Archival' ENTMAP off
COLUMN oldest_online_log_sequence FORMAT 999999999999999 HEADING 'Oldest Online |Log Sequence' ENTMAP off
COLUMN current_log_seq FORMAT 999999999999999 HEADING 'Current |Log Sequence' ENTMAP off
SELECT
'
, '
, c.current_log_seq current_log_seq
, o.oldest_online_log_sequence oldest_online_log_sequence
FROM
(select
DECODE( log_mode
, 'ARCHIVELOG', 'Archive Mode'
, 'NOARCHIVELOG', 'No Archive Mode'
, log_mode
) log_mode
from v$database
) d
, (select
DECODE( log_mode
, 'ARCHIVELOG', 'Enabled'
, 'NOARCHIVELOG', 'Disabled') log_archive_start
from v$database
) p
, (select a.sequence# current_log_seq
from v$log a
where a.status = 'CURRENT'
and thread# = &_thread_number
) c
, (select min(a.sequence#) oldest_online_log_sequence
from v$log a
where thread# = &_thread_number
) o
/
prompt
-- +----------------------------------------------------------------------------+
-- | - ARCHIVE DESTINATIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Archive Destinations
CLEAR COLUMNS BREAKS COMPUTES
COLUMN dest_id HEADING 'Destination|ID' ENTMAP off
COLUMN dest_name HEADING 'Destination|Name' ENTMAP off
COLUMN destination HEADING 'Destination' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN schedule HEADING 'Schedule' ENTMAP off
COLUMN archiver HEADING 'Archiver' ENTMAP off
COLUMN log_sequence FORMAT 999999999999999 HEADING 'Current Log|Sequence' ENTMAP off
SELECT
'
, a.dest_name dest_name
, a.destination destination
, DECODE( a.status
, 'VALID', '
, 'INACTIVE', '
, '
, DECODE( a.schedule
, 'ACTIVE', '
, 'INACTIVE', '
, '
, a.archiver archiver
, a.log_sequence log_sequence
FROM
v$archive_dest a
ORDER BY
a.dest_id
/
prompt
-- +----------------------------------------------------------------------------+
-- | - ARCHIVING INSTANCE PARAMETERS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Archiving Instance Parameters
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name HEADING 'Parameter Name' ENTMAP off
COLUMN value HEADING 'Parameter Value' ENTMAP off
SELECT
'' || a.name || '' name
, a.value value
FROM
v$parameter a
WHERE
a.name like 'log_%'
ORDER BY
a.name;
prompt
-- +----------------------------------------------------------------------------+
-- | - ARCHIVING HISTORY - |
-- +----------------------------------------------------------------------------+
prompt
prompt Archiving History
CLEAR COLUMNS BREAKS COMPUTES
COLUMN thread# FORMAT a79 HEADING 'Thread#' ENTMAP off
COLUMN sequence# FORMAT a79 HEADING 'Sequence#' ENTMAP off
COLUMN name HEADING 'Name' ENTMAP off
COLUMN first_change# HEADING 'First|Change #' ENTMAP off
COLUMN first_time FORMAT a75 HEADING 'First|Time' ENTMAP off
COLUMN next_change# HEADING 'Next|Change #' ENTMAP off
COLUMN next_time FORMAT a75 HEADING 'Next|Time' ENTMAP off
COLUMN log_size FORMAT 999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP off
COLUMN archived FORMAT a31 HEADING 'Archived?' ENTMAP off
COLUMN applied FORMAT a31 HEADING 'Applied?' ENTMAP off
COLUMN deleted FORMAT a31 HEADING 'Deleted?' ENTMAP off
COLUMN status FORMAT a75 HEADING 'Status' ENTMAP off
BREAK ON report ON thread#
SELECT
'
, '
, name
, first_change#
, '
, next_change#
, '
, (blocks * block_size) log_size
, '
, '
, '
, DECODE( status
, 'A', '
, 'D', '
, 'U', '
, 'X', '
) status
FROM
v$archived_log
WHERE
status in ('A')
ORDER BY
thread#
, sequence#;
prompt
-- +----------------------------------------------------------------------------+
-- | - FLASH RECOVERY AREA PARAMETERS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Flash Recovery Area Parameters
prompt db_recovery_file_dest_size is specified in bytes
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a95 HEADING 'Instance Name' ENTMAP off
COLUMN thread_number_print FORMAT a95 HEADING 'Thread Number' ENTMAP off
COLUMN name FORMAT a125 HEADING 'Name' ENTMAP off
COLUMN value HEADING 'Value' ENTMAP off
BREAK ON report ON instance_name_print ON thread_number_print
SELECT
'
, '
, '
, (CASE p.name
WHEN 'db_recovery_file_dest_size' THEN '
ELSE
'
END) value
FROM
gv$parameter p
, gv$instance i
WHERE
p.inst_id = i.inst_id
AND p.name IN ('db_recovery_file_dest_size', 'db_recovery_file_dest')
ORDER BY
1
, 3;
prompt
-- +----------------------------------------------------------------------------+
-- | - FLASH RECOVERY AREA STATUS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Flash Recovery Area Status
prompt Current location, disk quota, space in use, space reclaimable by deleting files, and number of files in the Flash Recovery Area
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name FORMAT a75 HEADING 'Name' ENTMAP off
COLUMN space_limit FORMAT 99,999,999,999,999 HEADING 'Space Limit' ENTMAP off
COLUMN space_used FORMAT 99,999,999,999,999 HEADING 'Space Used' ENTMAP off
COLUMN space_used_pct FORMAT 999.99 HEADING '% Used' ENTMAP off
COLUMN space_reclaimable FORMAT 99,999,999,999,999 HEADING 'Space Reclaimable' ENTMAP off
COLUMN pct_reclaimable FORMAT 999.99 HEADING '% Reclaimable' ENTMAP off
COLUMN number_of_files FORMAT 999,999 HEADING 'Number of Files' ENTMAP off
SELECT
'
, space_limit space_limit
, space_used space_used
, ROUND((space_used / DECODE(space_limit, 0, 0.000001, space_limit))*100, 2) space_used_pct
, space_reclaimable space_reclaimable
, ROUND((space_reclaimable / DECODE(space_limit, 0, 0.000001, space_limit))*100, 2) pct_reclaimable
, number_of_files number_of_files
FROM
v$recovery_file_dest
ORDER BY
name;
CLEAR COLUMNS BREAKS COMPUTES
COLUMN file_type FORMAT a75 HEADING 'File Type'
COLUMN percent_space_used HEADING 'Percent Space Used'
COLUMN percent_space_reclaimable HEADING 'Percent Space Reclaimable'
COLUMN number_of_files FORMAT 999,999 HEADING 'Number of Files'
SELECT
'
, percent_space_used percent_space_used
, percent_space_reclaimable percent_space_reclaimable
, number_of_files number_of_files
FROM
v$flash_recovery_area_usage;
prompt
-- +============================================================================+
-- | |
-- | <<<<< FLASHBACK TECHNOLOGIES >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - FLASHBACK DATABASE PARAMETERS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Flashback Database Parameters
prompt db_flashback_retention_target is specified in minutes
prompt db_recovery_file_dest_size is specified in bytes
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a95 HEADING 'Instance Name' ENTMAP off
COLUMN thread_number_print FORMAT a95 HEADING 'Thread Number' ENTMAP off
COLUMN name FORMAT a125 HEADING 'Name' ENTMAP off
COLUMN value HEADING 'Value' ENTMAP off
BREAK ON report ON instance_name_print ON thread_number_print
SELECT
'
, '
, '
, (CASE p.name
WHEN 'db_recovery_file_dest_size' THEN '
WHEN 'db_flashback_retention_target' THEN '
ELSE
'
END) value
FROM
gv$parameter p
, gv$instance i
WHERE
p.inst_id = i.inst_id
AND p.name IN ('db_flashback_retention_target', 'db_recovery_file_dest_size', 'db_recovery_file_dest')
ORDER BY
1
, 3;
prompt
-- +----------------------------------------------------------------------------+
-- | - FLASHBACK DATABASE STATUS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Flashback Database Status
CLEAR COLUMNS BREAKS COMPUTES
COLUMN dbid HEADING 'DB ID' ENTMAP off
COLUMN name FORMAT A75 HEADING 'DB Name' ENTMAP off
COLUMN log_mode FORMAT A75 HEADING 'Log Mode' ENTMAP off
COLUMN flashback_on FORMAT A75 HEADING 'Flashback DB On?' ENTMAP off
SELECT
'
, '
, '
, '
FROM v$database;
CLEAR COLUMNS BREAKS COMPUTES
COLUMN oldest_flashback_time FORMAT a125 HEADING 'Oldest Flashback Time' ENTMAP off
COLUMN oldest_flashback_scn HEADING 'Oldest Flashback SCN' ENTMAP off
COLUMN retention_target FORMAT 999,999 HEADING 'Retention Target (min)' ENTMAP off
COLUMN retention_target_hours FORMAT 999,999 HEADING 'Retention Target (hour)' ENTMAP off
COLUMN flashback_size FORMAT 9,999,999,999,999 HEADING 'Flashback Size' ENTMAP off
COLUMN estimated_flashback_size FORMAT 9,999,999,999,999 HEADING 'Estimated Flashback Size' ENTMAP off
SELECT
'
, oldest_flashback_scn oldest_flashback_scn
, retention_target retention_target
, retention_target/60 retention_target_hours
, flashback_size flashback_size
, estimated_flashback_size estimated_flashback_size
FROM
v$flashback_database_log
ORDER BY
1;
prompt
-- +----------------------------------------------------------------------------+
-- | - FLASHBACK DATABASE REDO TIME MATRIX - |
-- +----------------------------------------------------------------------------+
prompt
prompt Flashback Database Redo Time Matrix
CLEAR COLUMNS BREAKS COMPUTES
COLUMN begin_time FORMAT a75 HEADING 'Begin Time' ENTMAP off
COLUMN end_time FORMAT a75 HEADING 'End Time' ENTMAP off
COLUMN flashback_data FORMAT 9,999,999,999,999 HEADING 'Flashback Data' ENTMAP off
COLUMN db_data FORMAT 9,999,999,999,999 HEADING 'DB Data' ENTMAP off
COLUMN redo_data FORMAT 9,999,999,999,999 HEADING 'Redo Data' ENTMAP off
COLUMN estimated_flashback_size FORMAT 9,999,999,999,999 HEADING 'Estimated Flashback Size' ENTMAP off
SELECT
'
, '
, flashback_data
, db_data
, redo_data
, estimated_flashback_size
FROM
v$flashback_database_stat
ORDER BY
begin_time;
prompt
-- +============================================================================+
-- | |
-- | <<<<< PERFORMANCE >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - SGA INFORMATION - |
-- +----------------------------------------------------------------------------+
prompt
prompt SGA Information
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a79 HEADING 'Instance Name' ENTMAP off
COLUMN name FORMAT a150 HEADING 'Pool Name' ENTMAP off
COLUMN value FORMAT 999,999,999,999,999 HEADING 'Bytes' ENTMAP off
BREAK ON report ON instance_name
COMPUTE sum LABEL 'Total:' OF value ON instance_name
SELECT
'
, '
, s.value value
FROM
gv$sga s
, gv$instance i
WHERE
s.inst_id = i.inst_id
ORDER BY
i.instance_name
, s.value DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - SGA TARGET ADVICE - |
-- +----------------------------------------------------------------------------+
prompt
prompt SGA Target Advice
prompt Modify the SGA_TARGET parameter (up to the size of the SGA_MAX_SIZE, if necessary) to reduce
prompt the number of "Estimated Physical Reads".
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a79 HEADING 'Instance Name' ENTMAP off
COLUMN name FORMAT a79 HEADING 'Parameter Name' ENTMAP off
COLUMN value FORMAT a79 HEADING 'Value' ENTMAP off
BREAK ON report ON instance_name
SELECT
'
, p.name name
, (CASE p.name
WHEN 'sga_max_size' THEN '
WHEN 'sga_target' THEN '
ELSE
'
END) value
FROM
gv$parameter p
, gv$instance i
WHERE
p.inst_id = i.inst_id
AND p.name IN ('sga_max_size', 'sga_target')
ORDER BY
i.instance_name
, p.name;
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a79 HEADING 'Instance Name' ENTMAP off
COLUMN sga_size FORMAT 999,999,999,999,999 HEADING 'SGA Size' ENTMAP off
COLUMN sga_size_factor FORMAT 999,999,999,999,999 HEADING 'SGA Size Factor' ENTMAP off
COLUMN estd_db_time FORMAT 999,999,999,999,999 HEADING 'Estimated DB Time' ENTMAP off
COLUMN estd_db_time_factor FORMAT 999,999,999,999,999 HEADING 'Estimated DB Time Factor' ENTMAP off
COLUMN estd_physical_reads FORMAT 999,999,999,999,999 HEADING 'Estimated Physical Reads' ENTMAP off
BREAK ON report ON instance_name
SELECT
'
, s.sga_size
, s.sga_size_factor
, s.estd_db_time
, s.estd_db_time_factor
, s.estd_physical_reads
FROM
gv$sga_target_advice s
, gv$instance i
WHERE
s.inst_id = i.inst_id
ORDER BY
i.instance_name
, s.sga_size_factor;
prompt
-- +----------------------------------------------------------------------------+
-- | - SGA (ASMM) DYNAMIC COMPONENTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt SGA (ASMM) Dynamic Components
prompt Provides a summary report of all dynamic components as part of the Automatic Shared Memory
prompt Management (ASMM) configuration. This will display the total real memory allocation for the current
prompt SGA from the V$SGA_DYNAMIC_COMPONENTS view, which contains both manual and autotuned SGA components.
prompt As with the other manageability features of Oracle Database 10g, ASMM requires you to set the
prompt STATISTICS_LEVEL parameter to at least TYPICAL (the default) before attempting to enable ASMM. ASMM
prompt can be enabled by setting SGA_TARGET to a nonzero value in the initialization parameter file (pfile/spfile).
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a79 HEADING 'Instance Name' ENTMAP off
COLUMN component FORMAT a79 HEADING 'Component Name' ENTMAP off
COLUMN current_size FORMAT 999,999,999,999 HEADING 'Current Size' ENTMAP off
COLUMN min_size FORMAT 999,999,999,999 HEADING 'Min Size' ENTMAP off
COLUMN max_size FORMAT 999,999,999,999 HEADING 'Max Size' ENTMAP off
COLUMN user_specified_size FORMAT 999,999,999,999 HEADING 'User Specified|Size' ENTMAP off
COLUMN oper_count FORMAT 999,999,999,999 HEADING 'Oper.|Count' ENTMAP off
COLUMN last_oper_type FORMAT a75 HEADING 'Last Oper.|Type' ENTMAP off
COLUMN last_oper_mode FORMAT a75 HEADING 'Last Oper.|Mode' ENTMAP off
COLUMN last_oper_time FORMAT a75 HEADING 'Last Oper.|Time' ENTMAP off
COLUMN granule_size FORMAT 999,999,999,999 HEADING 'Granule Size' ENTMAP off
BREAK ON report ON instance_name
SELECT
'
, sdc.component
, sdc.current_size
, sdc.min_size
, sdc.max_size
, sdc.user_specified_size
, sdc.oper_count
, sdc.last_oper_type
, sdc.last_oper_mode
, '
') || '
, sdc.granule_size
FROM
gv$sga_dynamic_components sdc
, gv$instance i
ORDER BY
i.instance_name
, sdc.component DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - PGA TARGET ADVICE - |
-- +----------------------------------------------------------------------------+
prompt
prompt PGA Target Advice
prompt The V$PGA_TARGET_ADVICE view predicts how the statistics cache hit percentage and over
prompt allocation count in V$PGASTAT will be impacted if you change the value of the
prompt initialization parameter PGA_AGGREGATE_TARGET. When you set the PGA_AGGREGATE_TARGET and
prompt WORKAREA_SIZE_POLICY to AUTO then the *_AREA_SIZE parameter are automatically ignored and
prompt Oracle will automatically use the computed value for these parameters. Use the results from
prompt the query below to adequately set the initialization parameter PGA_AGGREGATE_TARGET as to avoid
prompt any over allocation. If column ESTD_OVERALLOCATION_COUNT in the V$PGA_TARGET_ADVICE
prompt view (below) is nonzero, it indicates that PGA_AGGREGATE_TARGET is too small to even
prompt meet the minimum PGA memory needs. If PGA_AGGREGATE_TARGET is set within the over
prompt allocation zone, the memory manager will over-allocate memory and actual PGA memory
prompt consumed will be more than the limit you set. It is therefore meaningless to set a
prompt value of PGA_AGGREGATE_TARGET in that zone. After eliminating over-allocations, the
prompt goal is to maximize the PGA cache hit percentage, based on your response-time requirement
prompt and memory constraints.
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a79 HEADING 'Instance Name' ENTMAP off
COLUMN name FORMAT a79 HEADING 'Parameter Name' ENTMAP off
COLUMN value FORMAT a79 HEADING 'Value' ENTMAP off
BREAK ON report ON instance_name
SELECT
'
, p.name name
, (CASE p.name
WHEN 'pga_aggregate_target' THEN '
ELSE
'
END) value
FROM
gv$parameter p
, gv$instance i
WHERE
p.inst_id = i.inst_id
AND p.name IN ('pga_aggregate_target', 'workarea_size_policy')
ORDER BY
i.instance_name
, p.name;
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name FORMAT a79 HEADING 'Instance Name' ENTMAP off
COLUMN pga_target_for_estimate FORMAT 999,999,999,999,999 HEADING 'PGA Target for Estimate' ENTMAP off
COLUMN estd_extra_bytes_rw FORMAT 999,999,999,999,999 HEADING 'Estimated Extra Bytes R/W' ENTMAP off
COLUMN estd_pga_cache_hit_percentage FORMAT 999,999,999,999,999 HEADING 'Estimated PGA Cache Hit %' ENTMAP off
COLUMN estd_overalloc_count FORMAT 999,999,999,999,999 HEADING 'ESTD_OVERALLOC_COUNT' ENTMAP off
BREAK ON report ON instance_name
SELECT
'
, p.pga_target_for_estimate
, p.estd_extra_bytes_rw
, p.estd_pga_cache_hit_percentage
, p.estd_overalloc_count
FROM
gv$pga_target_advice p
, gv$instance i
WHERE
p.inst_id = i.inst_id
ORDER BY
i.instance_name
, p.pga_target_for_estimate;
prompt
-- +----------------------------------------------------------------------------+
-- | - FILE I/O STATISTICS - |
-- +----------------------------------------------------------------------------+
prompt
prompt File I/O Statistics
prompt Ordered by "Physical Reads" since last startup of the Oracle instance
CLEAR COLUMNS BREAKS COMPUTES
COLUMN tablespace_name FORMAT a50 HEAD 'Tablespace' ENTMAP off
COLUMN fname HEAD 'File Name' ENTMAP off
COLUMN phyrds FORMAT 999,999,999,999,999 HEAD 'Physical Reads' ENTMAP off
COLUMN phywrts FORMAT 999,999,999,999,999 HEAD 'Physical Writes' ENTMAP off
COLUMN read_pct HEAD 'Read Pct.' ENTMAP off
COLUMN write_pct HEAD 'Write Pct.' ENTMAP off
COLUMN total_io FORMAT 999,999,999,999,999 HEAD 'Total I/O' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total: ' OF phyrds phywrts total_io ON report
SELECT
'' || df.tablespace_name || '' tablespace_name
, df.file_name fname
, fs.phyrds phyrds
, '
, fs.phywrts phywrts
, '
, (fs.phyrds + fs.phywrts) total_io
FROM
sys.dba_data_files df
, v$filestat fs
, (select sum(f.phyrds) pr, sum(f.phywrts) pw from v$filestat f) fst
, (select sum(t.phyrds) pr, sum(t.phywrts) pw from v$tempstat t) tst
WHERE
df.file_id = fs.file#
UNION
SELECT
'' || tf.tablespace_name || '' tablespace_name
, tf.file_name fname
, ts.phyrds phyrds
, '
, ts.phywrts phywrts
, '
, (ts.phyrds + ts.phywrts) total_io
FROM
sys.dba_temp_files tf
, v$tempstat ts
, (select sum(f.phyrds) pr, sum(f.phywrts) pw from v$filestat f) fst
, (select sum(t.phyrds) pr, sum(t.phywrts) pw from v$tempstat t) tst
WHERE
tf.file_id = ts.file#
ORDER BY phyrds DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - FILE I/O TIMINGS - |
-- +----------------------------------------------------------------------------+
prompt
prompt File I/O Timings
prompt Average time (in milliseconds) for an I/O call per datafile since last startup of the Oracle instance - (ordered by Physical Reads)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN fname HEAD 'File Name' ENTMAP off
COLUMN phyrds FORMAT 999,999,999,999,999 HEAD 'Physical Reads' ENTMAP off
COLUMN read_rate FORMAT 999,999,999,999,999.99 HEAD 'Average Read Time
(milliseconds per read)' ENTMAP off
COLUMN phywrts FORMAT 999,999,999,999,999 HEAD 'Physical Writes' ENTMAP off
COLUMN write_rate FORMAT 999,999,999,999,999.99 HEAD 'Average Write Time
(milliseconds per write)' ENTMAP off
BREAK ON REPORT
COMPUTE sum LABEL 'Total: ' OF phyrds phywrts ON report
COMPUTE avg LABEL 'Average: ' OF read_rate write_rate ON report
SELECT
'' || d.name || '' fname
, s.phyrds phyrds
, ROUND((s.readtim/GREATEST(s.phyrds,1)), 2) read_rate
, s.phywrts phywrts
, ROUND((s.writetim/GREATEST(s.phywrts,1)),2) write_rate
FROM
v$filestat s
, v$datafile d
WHERE
s.file# = d.file#
UNION
SELECT
'' || t.name || '' fname
, s.phyrds phyrds
, ROUND((s.readtim/GREATEST(s.phyrds,1)), 2) read_rate
, s.phywrts phywrts
, ROUND((s.writetim/GREATEST(s.phywrts,1)),2) write_rate
FROM
v$tempstat s
, v$tempfile t
WHERE
s.file# = t.file#
ORDER BY
2 DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - AVERAGE OVERALL I/O PER SECOND - |
-- +----------------------------------------------------------------------------+
prompt
prompt Average Overall I/O per Second
prompt Average overall I/O calls (physical read/write calls) since last startup of the Oracle instance
CLEAR COLUMNS BREAKS COMPUTES
DECLARE
CURSOR get_file_io IS
SELECT
NVL(SUM(a.phyrds + a.phywrts), 0) sum_datafile_io
, TO_NUMBER(null) sum_tempfile_io
FROM
v$filestat a
UNION
SELECT
TO_NUMBER(null) sum_datafile_io
, NVL(SUM(b.phyrds + b.phywrts), 0) sum_tempfile_io
FROM
v$tempstat b;
current_time DATE;
elapsed_time_seconds NUMBER;
sum_datafile_io NUMBER;
sum_datafile_io2 NUMBER;
sum_tempfile_io NUMBER;
sum_tempfile_io2 NUMBER;
total_io NUMBER;
datafile_io_per_sec NUMBER;
tempfile_io_per_sec NUMBER;
total_io_per_sec NUMBER;
BEGIN
OPEN get_file_io;
FOR i IN 1..2 LOOP
FETCH get_file_io INTO sum_datafile_io, sum_tempfile_io;
IF i = 1 THEN
sum_datafile_io2 := sum_datafile_io;
ELSE
sum_tempfile_io2 := sum_tempfile_io;
END IF;
END LOOP;
total_io := sum_datafile_io2 + sum_tempfile_io2;
SELECT sysdate INTO current_time FROM dual;
SELECT CEIL ((current_time - startup_time)*(60*60*24)) INTO elapsed_time_seconds FROM v$instance;
datafile_io_per_sec := sum_datafile_io2/elapsed_time_seconds;
tempfile_io_per_sec := sum_tempfile_io2/elapsed_time_seconds;
total_io_per_sec := total_io/elapsed_time_seconds;
DBMS_OUTPUT.PUT_LINE('
Elapsed Time (in seconds) | ' || TO_CHAR(elapsed_time_seconds, '9,999,999,999,999') || ' |
---|---|
Datafile I/O Calls per Second | ' || TO_CHAR(datafile_io_per_sec, '9,999,999,999,999') || ' |
Tempfile I/O Calls per Second | ' || TO_CHAR(tempfile_io_per_sec, '9,999,999,999,999') || ' |
Total I/O Calls per Second | ' || TO_CHAR(total_io_per_sec, '9,999,999,999,999') || ' |
END;
/
prompt
-- +----------------------------------------------------------------------------+
-- | - REDO LOG CONTENTION - |
-- +----------------------------------------------------------------------------+
prompt
prompt Redo Log Contention
prompt All latches like redo% - (ordered by misses)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name FORMAT a95 HEADING 'Latch Name'
COLUMN gets FORMAT 999,999,999,999,999,999 HEADING 'Gets'
COLUMN misses FORMAT 999,999,999,999 HEADING 'Misses'
COLUMN sleeps FORMAT 999,999,999,999 HEADING 'Sleeps'
COLUMN immediate_gets FORMAT 999,999,999,999,999,999 HEADING 'Immediate Gets'
COLUMN immediate_misses FORMAT 999,999,999,999 HEADING 'Immediate Misses'
BREAK ON report
COMPUTE sum LABEL 'Total:' OF gets misses sleeps immediate_gets immediate_misses ON report
SELECT
'
, gets
, misses
, sleeps
, immediate_gets
, immediate_misses
FROM sys.v_$latch
WHERE name LIKE 'redo%'
ORDER BY 1;
prompt
prompt System statistics like redo%
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name FORMAT a95 HEADING 'Statistics Name'
COLUMN value FORMAT 999,999,999,999,999 HEADING 'Value'
SELECT
'
, value
FROM v$sysstat
WHERE name LIKE 'redo%'
ORDER BY 1;
prompt
-- +----------------------------------------------------------------------------+
-- | - FULL TABLE SCANS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Full Table Scans
CLEAR COLUMNS BREAKS COMPUTES
COLUMN large_table_scans FORMAT 999,999,999,999,999 HEADING 'Large Table Scans' ENTMAP off
COLUMN small_table_scans FORMAT 999,999,999,999,999 HEADING 'Small Table Scans' ENTMAP off
COLUMN pct_large_scans HEADING 'Pct. Large Scans' ENTMAP off
SELECT
a.value large_table_scans
, b.value small_table_scans
, '
FROM
v$sysstat a
, v$sysstat b
WHERE
a.name = 'table scans (long tables)'
AND b.name = 'table scans (short tables)';
prompt
-- +----------------------------------------------------------------------------+
-- | - SORTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Sorts
CLEAR COLUMNS BREAKS COMPUTES
COLUMN disk_sorts FORMAT 999,999,999,999,999 HEADING 'Disk Sorts' ENTMAP off
COLUMN memory_sorts FORMAT 999,999,999,999,999 HEADING 'Memory Sorts' ENTMAP off
COLUMN pct_disk_sorts HEADING 'Pct. Disk Sorts' ENTMAP off
SELECT
a.value disk_sorts
, b.value memory_sorts
, '
FROM
v$sysstat a
, v$sysstat b
WHERE
a.name = 'sorts (disk)'
AND b.name = 'sorts (memory)';
prompt
-- +----------------------------------------------------------------------------+
-- | - OUTLINES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Outlines
CLEAR COLUMNS BREAKS COMPUTES
COLUMN category FORMAT a125 HEADING 'Category' ENTMAP off
COLUMN owner FORMAT a125 HEADING 'Owner' ENTMAP off
COLUMN name FORMAT a125 HEADING 'Name' ENTMAP off
COLUMN used HEADING 'Used?' ENTMAP off
COLUMN timestamp FORMAT a125 HEADING 'Time Stamp' ENTMAP off
COLUMN version HEADING 'Version' ENTMAP off
COLUMN sql_text HEADING 'SQL Text' ENTMAP off
SELECT
'
, owner
, name
, used
, '
, version
, sql_text
FROM
dba_outlines
ORDER BY
category
, owner
, name;
prompt
-- +----------------------------------------------------------------------------+
-- | - OUTLINE HINTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Outline Hints
CLEAR COLUMNS BREAKS COMPUTES
COLUMN category FORMAT a125 HEADING 'Category' ENTMAP off
COLUMN owner FORMAT a125 HEADING 'Owner' ENTMAP off
COLUMN name FORMAT a125 HEADING 'Name' ENTMAP off
COLUMN node HEADING 'Node' ENTMAP off
COLUMN join_pos HEADING 'Join Position' ENTMAP off
COLUMN hint HEADING 'Hint' ENTMAP off
BREAK ON category ON owner ON name
SELECT
'
, a.owner owner
, a.name name
, '
, '
, b.hint hint
FROM
dba_outlines a
, dba_outline_hints b
WHERE
a.owner = b.owner
AND b.name = b.name
ORDER BY
category
, owner
, name;
prompt
-- +----------------------------------------------------------------------------+
-- | - SQL STATEMENTS WITH MOST BUFFER GETS - |
-- +----------------------------------------------------------------------------+
prompt
prompt SQL Statements With Most Buffer Gets
prompt Top 100 SQL statements with buffer gets greater than 1000
CLEAR COLUMNS BREAKS COMPUTES
COLUMN username FORMAT a75 HEADING 'Username' ENTMAP off
COLUMN buffer_gets FORMAT 999,999,999,999,999 HEADING 'Buffer Gets' ENTMAP off
COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP off
COLUMN gets_per_exec FORMAT 999,999,999,999,999 HEADING 'Buffer Gets / Execution' ENTMAP off
COLUMN sql_text HEADING 'SQL Text' ENTMAP off
SELECT
'' || UPPER(b.username) || '' username
, a.buffer_gets buffer_gets
, a.executions executions
, (a.buffer_gets / decode(a.executions, 0, 1, a.executions)) gets_per_exec
, a.sql_text sql_text
FROM
(SELECT ai.buffer_gets, ai.executions, ai.sql_text, ai.parsing_user_id
FROM sys.v_$sqlarea ai
ORDER BY ai.buffer_gets
) a
, dba_users b
WHERE
a.parsing_user_id = b.user_id
AND a.buffer_gets > 1000
AND b.username NOT IN ('SYS','SYSTEM')
AND rownum < 101
ORDER BY
a.buffer_gets DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - SQL STATEMENTS WITH MOST DISK READS - |
-- +----------------------------------------------------------------------------+
prompt
prompt SQL Statements With Most Disk Reads
prompt Top 100 SQL statements with disk reads greater than 1000
CLEAR COLUMNS BREAKS COMPUTES
COLUMN username FORMAT a75 HEADING 'Username' ENTMAP off
COLUMN disk_reads FORMAT 999,999,999,999,999 HEADING 'Disk Reads' ENTMAP off
COLUMN executions FORMAT 999,999,999,999,999 HEADING 'Executions' ENTMAP off
COLUMN reads_per_exec FORMAT 999,999,999,999,999 HEADING 'Reads / Execution' ENTMAP off
COLUMN sql_text HEADING 'SQL Text' ENTMAP off
SELECT
'' || UPPER(b.username) || '' username
, a.disk_reads disk_reads
, a.executions executions
, (a.disk_reads / decode(a.executions, 0, 1, a.executions)) reads_per_exec
, a.sql_text sql_text
FROM
(SELECT ai.disk_reads, ai.executions, ai.sql_text, ai.parsing_user_id
FROM sys.v_$sqlarea ai
ORDER BY ai.buffer_gets
) a
, dba_users b
WHERE
a.parsing_user_id = b.user_id
AND a.disk_reads > 1000
AND b.username NOT IN ('SYS','SYSTEM')
AND rownum < 101
ORDER BY
a.disk_reads DESC;
prompt
-- +============================================================================+
-- | |
-- | <<<<< AUTOMATIC WORKLOAD REPOSITORY - (AWR) >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - WORKLOAD REPOSITORY INFORMATION - |
-- +----------------------------------------------------------------------------+
prompt
prompt Workload Repository Information
prompt Instances found in the "Workload Repository"
prompt The instance running this report (&_instance_name) is indicated in "GREEN"
CLEAR COLUMNS BREAKS COMPUTES
COLUMN dbbid FORMAT a75 HEAD 'Database ID' ENTMAP off
COLUMN dbb_name FORMAT a75 HEAD 'Database Name' ENTMAP off
COLUMN instt_name FORMAT a75 HEAD 'Instance Name' ENTMAP off
COLUMN instt_num FORMAT 9999999999 HEAD 'Instance Number' ENTMAP off
COLUMN host FORMAT a75 HEAD 'Host' ENTMAP off
COLUMN host_platform FORMAT a125 HEAD 'Host Platform' ENTMAP off
SELECT
DISTINCT (CASE WHEN cd.dbid = wr.dbid
AND
cd.name = wr.db_name
AND
ci.instance_number = wr.instance_number
AND
ci.instance_name = wr.instance_name
THEN '
ELSE '
END) dbbid
, wr.db_name dbb_name
, wr.instance_name instt_name
, wr.instance_number instt_num
, wr.host_name host
, cd.platform_name host_platform
FROM
dba_hist_database_instance wr
, v$database cd
, v$instance ci
ORDER BY
wr.instance_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - AWR SNAPSHOT SETTINGS - |
-- +----------------------------------------------------------------------------+
prompt
prompt AWR Snapshot Settings
prompt Use the DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS procedure to modify the interval
prompt of the snapshot generation and how long the snapshots are retained in the Workload Repository. The
prompt default interval is 60 minutes and can be set to a value between 10 minutes and 5,256,000 (1 year).
prompt The default retention period is 10,080 minutes (7 days) and can be set to a value between
prompt 1,440 minutes (1 day) and 52,560,000 minutes (100 years).
CLEAR COLUMNS BREAKS COMPUTES
COLUMN dbbid FORMAT a75 HEAD 'Database ID' ENTMAP off
COLUMN dbb_name FORMAT a75 HEAD 'Database Name' ENTMAP off
COLUMN snap_interval FORMAT a75 HEAD 'Snap Interval' ENTMAP off
COLUMN retention FORMAT a75 HEAD 'Retention Period' ENTMAP off
COLUMN topnsql FORMAT a75 HEAD 'Top N SQL' ENTMAP off
SELECT
'
, d.name dbb_name
, s.snap_interval snap_interval
, s.retention retention
, s.topnsql
FROM
dba_hist_wr_control s
, v$database d
WHERE
s.dbid = d.dbid
ORDER BY
dbbid;
prompt
-- +----------------------------------------------------------------------------+
-- | - AWR SNAPSHOT LIST - |
-- +----------------------------------------------------------------------------+
prompt
prompt AWR Snapshot List
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a75 HEADING 'Instance Name' ENTMAP off
COLUMN snap_id FORMAT a75 HEADING 'Snap ID' ENTMAP off
COLUMN startup_time FORMAT a75 HEADING 'Instance Startup Time' ENTMAP off
COLUMN begin_interval_time FORMAT a75 HEADING 'Begin Interval Time' ENTMAP off
COLUMN end_interval_time FORMAT a75 HEADING 'End Interval Time' ENTMAP off
COLUMN elapsed_time FORMAT 999,999,999.99 HEADING 'Elapsed Time (min)' ENTMAP off
COLUMN db_time FORMAT 999,999,999.99 HEADING 'DB Time (min)' ENTMAP off
COLUMN pct_db_time FORMAT a75 HEADING '% DB Time' ENTMAP off
COLUMN cpu_time FORMAT 999,999,999.99 HEADING 'CPU Time (min)' ENTMAP off
BREAK ON instance_name_print ON startup_time
SELECT
'
, '
, '
, '
, '
, ROUND(EXTRACT(DAY FROM s.end_interval_time - s.begin_interval_time) * 1440 +
EXTRACT(HOUR FROM s.end_interval_time - s.begin_interval_time) * 60 +
EXTRACT(MINUTE FROM s.end_interval_time - s.begin_interval_time) +
EXTRACT(SECOND FROM s.end_interval_time - s.begin_interval_time) / 60, 2) elapsed_time
, ROUND((e.value - b.value)/1000000/60, 2) db_time
, '
ROUND(((((e.value - b.value)/1000000/60) / (EXTRACT(DAY FROM s.end_interval_time - s.begin_interval_time) * 1440 +
EXTRACT(HOUR FROM s.end_interval_time - s.begin_interval_time) * 60 +
EXTRACT(MINUTE FROM s.end_interval_time - s.begin_interval_time) +
EXTRACT(SECOND FROM s.end_interval_time - s.begin_interval_time) / 60) ) * 100), 2)
|| ' %
FROM
dba_hist_snapshot s
, gv$instance i
, dba_hist_sys_time_model e
, dba_hist_sys_time_model b
WHERE
i.instance_number = s.instance_number
AND e.snap_id = s.snap_id
AND b.snap_id = s.snap_id - 1
AND e.stat_id = b.stat_id
AND e.instance_number = b.instance_number
AND e.instance_number = s.instance_number
AND e.stat_name = 'DB time'
ORDER BY
i.instance_name
, s.snap_id;
prompt
-- +----------------------------------------------------------------------------+
-- | - AWR SNAPSHOT SIZE ESTIMATES - |
-- +----------------------------------------------------------------------------+
prompt
prompt AWR Snapshot Size Estimates
DECLARE
CURSOR get_instances IS
SELECT COUNT(DISTINCT instance_number)
FROM wrm$_database_instance;
CURSOR get_wr_control_info IS
SELECT snapint_num, retention_num
FROM wrm$_wr_control;
CURSOR get_snaps IS
SELECT
SUM(all_snaps)
, SUM(good_snaps)
, SUM(today_snaps)
, SYSDATE - MIN(begin_interval_time)
FROM
(SELECT
1 AS all_snaps
, (CASE WHEN s.status = 0 THEN 1 ELSE 0 END) AS good_snaps
, (CASE WHEN (s.end_interval_time > SYSDATE - 1) THEN 1 ELSE 0 END) AS today_snaps
, CAST(s.begin_interval_time AS DATE) AS begin_interval_time
FROM wrm$_snapshot s
);
CURSOR sysaux_occ_usage IS
SELECT
occupant_name
, schema_name
, space_usage_kbytes/1024 space_usage_mb
FROM
v$sysaux_occupants
ORDER BY
space_usage_kbytes DESC
, occupant_name;
mb_format CONSTANT VARCHAR2(30) := '99,999,990.0';
kb_format CONSTANT VARCHAR2(30) := '999,999,990';
pct_format CONSTANT VARCHAR2(30) := '990.0';
snapshot_interval NUMBER;
retention_interval NUMBER;
all_snaps NUMBER;
awr_size NUMBER;
snap_size NUMBER;
awr_average_size NUMBER;
est_today_snaps NUMBER;
awr_size_past24 NUMBER;
good_snaps NUMBER;
today_snaps NUMBER;
num_days NUMBER;
num_instances NUMBER;
BEGIN
OPEN get_instances;
FETCH get_instances INTO num_instances;
CLOSE get_instances;
OPEN get_wr_control_info;
FETCH get_wr_control_info INTO snapshot_interval, retention_interval;
CLOSE get_wr_control_info;
OPEN get_snaps;
FETCH get_snaps INTO all_snaps, good_snaps, today_snaps, num_days;
CLOSE get_snaps;
FOR occ_rec IN sysaux_occ_usage
LOOP
IF (occ_rec.occupant_name = 'SM/AWR') THEN
awr_size := occ_rec.space_usage_mb;
END IF;
END LOOP;
snap_size := awr_size/all_snaps;
awr_average_size := snap_size*86400/snapshot_interval;
today_snaps := today_snaps / num_instances;
IF (num_days < 1) THEN
est_today_snaps := ROUND(today_snaps / num_days);
ELSE
est_today_snaps := today_snaps;
END IF;
awr_size_past24 := snap_size * est_today_snaps;
DBMS_OUTPUT.PUT_LINE('
Estimates based on ' || ROUND(snapshot_interval/60) || ' minute snapshot intervals | ||
---|---|---|
AWR size/day | '
|| TO_CHAR(awr_average_size, mb_format) || ' MB | (' || TRIM(TO_CHAR(snap_size*1024, kb_format)) || ' K/snap * '
|| ROUND(86400/snapshot_interval) || ' snaps/day) |
AWR size/wk | '
|| TO_CHAR(awr_average_size * 7, mb_format) || ' MB | (size_per_day * 7) per instance |
AWR size/wk | '
|| TO_CHAR(awr_average_size * 7 * num_instances, mb_format) || ' MB | (size_per_day * 7) per database |
Estimates based on ' || ROUND(today_snaps) || ' snaps in past 24 hours | ||
AWR size/day | '
|| TO_CHAR(awr_size_past24, mb_format) || ' MB | ('
|| TRIM(TO_CHAR(snap_size*1024, kb_format)) || ' K/snap and ' || ROUND(today_snaps) || ' snaps in past ' || ROUND(least(num_days*24,24),1) || ' hours) |
AWR size/wk | '
|| TO_CHAR(awr_size_past24 * 7, mb_format) || ' MB | (size_per_day * 7) per instance |
AWR size/wk | '
|| TO_CHAR(awr_size_past24 * 7 * num_instances, mb_format) || ' MB | (size_per_day * 7) per database |
END;
/
prompt
-- +----------------------------------------------------------------------------+
-- | - AWR BASELINES - |
-- +----------------------------------------------------------------------------+
prompt
prompt AWR Baselines
prompt Use the DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE procedure to create a named baseline.
prompt A baseline (also known as a preserved snapshot set) is a pair of AWR snapshots that represents a
prompt specific period of database usage. The Oracle database server will exempt the AWR snapshots
prompt assigned to a specific baseline from the automated purge routine. The main purpose of a baseline
prompt is to preserve typical run-time statistics in the AWR repository which can then be compared to
prompt current performance or similar periods in the past.
CLEAR COLUMNS BREAKS COMPUTES
COLUMN dbbid FORMAT a75 HEAD 'Database ID' ENTMAP off
COLUMN dbb_name FORMAT a75 HEAD 'Database Name' ENTMAP off
COLUMN baseline_id HEAD 'Baseline ID' ENTMAP off
COLUMN baseline_name FORMAT a75 HEAD 'Baseline Name' ENTMAP off
COLUMN start_snap_id HEAD 'Beginning Snapshot ID' ENTMAP off
COLUMN start_snap_time FORMAT a75 HEAD 'Beginning Snapshot Time' ENTMAP off
COLUMN end_snap_id HEAD 'Ending Snapshot ID' ENTMAP off
COLUMN end_snap_time FORMAT a75 HEAD 'Ending Snapshot Time' ENTMAP off
SELECT
'
, d.name dbb_name
, b.baseline_id baseline_id
, baseline_name baseline_name
, b.start_snap_id start_snap_id
, '
, b.end_snap_id end_snap_id
, '
FROM
dba_hist_baseline b
, v$database d
WHERE
b.dbid = d.dbid
ORDER BY
dbbid
, b.baseline_id;
prompt
-- +============================================================================+
-- | |
-- | <<<<< SESSIONS >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - CURRENT SESSIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Current Sessions
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a45 HEADING 'Instance Name' ENTMAP off
COLUMN thread_number_print FORMAT a45 HEADING 'Thread Number' ENTMAP off
COLUMN count FORMAT a45 HEADING 'Current No. of Processes' ENTMAP off
COLUMN value FORMAT a45 HEADING 'Max No. of Processes' ENTMAP off
COLUMN pct_usage FORMAT a45 HEADING '% Usage' ENTMAP off
SELECT
'
, '
, '
, '
, '
FROM
(select count(*) count, a1.inst_id, a2.instance_name, a2.thread#
from gv$session a1
, gv$instance a2
where a1.inst_id = a2.inst_id
group by a1.inst_id
, a2.instance_name
, a2.thread#) a
, (select value, inst_id from gv$parameter where name='processes') b
WHERE
a.inst_id = b.inst_id
ORDER BY
a.instance_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - USER SESSION MATRIX - |
-- +----------------------------------------------------------------------------+
prompt
prompt User Session Matrix
prompt User sessions (excluding SYS and background processes)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a75 HEADING 'Instance Name' ENTMAP off
COLUMN thread_number_print FORMAT a75 HEADING 'Thread Number' ENTMAP off
COLUMN username FORMAT a79 HEADING 'Oracle User' ENTMAP off
COLUMN num_user_sess FORMAT 999,999,999,999 HEADING 'Total Number of Logins' ENTMAP off
COLUMN count_a FORMAT 999,999,999 HEADING 'Active Logins' ENTMAP off
COLUMN count_i FORMAT 999,999,999 HEADING 'Inactive Logins' ENTMAP off
COLUMN count_k FORMAT 999,999,999 HEADING 'Killed Logins' ENTMAP off
BREAK ON report ON instance_name_print ON thread_number_print
SELECT
'
, '
, '
, count(*) num_user_sess
, NVL(act.count, 0) count_a
, NVL(inact.count, 0) count_i
, NVL(killed.count, 0) count_k
FROM
gv$session sess
, gv$instance i
, (SELECT count(*) count, NVL(username, '[B.G. Process]') username, inst_id
FROM gv$session
WHERE status = 'ACTIVE'
GROUP BY username, inst_id) act
, (SELECT count(*) count, NVL(username, '[B.G. Process]') username, inst_id
FROM gv$session
WHERE status = 'INACTIVE'
GROUP BY username, inst_id) inact
, (SELECT count(*) count, NVL(username, '[B.G. Process]') username, inst_id
FROM gv$session
WHERE status = 'KILLED'
GROUP BY username, inst_id) killed
WHERE
sess.inst_id = i.inst_id
AND (
NVL(sess.username, '[B.G. Process]') = act.username (+)
AND
sess.inst_id = act.inst_id (+)
)
AND (
NVL(sess.username, '[B.G. Process]') = inact.username (+)
AND
sess.inst_id = inact.inst_id (+)
)
AND (
NVL(sess.username, '[B.G. Process]') = killed.username (+)
AND
sess.inst_id = killed.inst_id (+)
)
AND sess.username NOT IN ('SYS')
GROUP BY
i.instance_name
, i.thread#
, sess.username
, act.count
, inact.count
, killed.count
ORDER BY
i.instance_name
, i.thread#
, sess.username;
prompt
-- +----------------------------------------------------------------------------+
-- | - ENABLED TRACES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Enabled Traces
prompt End-to-End Application Tracing from View DBA_ENABLED_TRACES.
prompt
prompt
prompt
prompt Application tracing is enabled using the DBMS_MONITOR package and the following procedures:
prompt
prompt
prompt
prompt
prompt
prompt
prompt
prompt
prompt
prompt Hint: In a shared environment where you have more than one session to trace, it is
prompt possible to end up with many trace files when tracing is enabled (i.e. connection pools).
prompt Oracle10g introduces the trcsess command-line utility to combine all the relevant
prompt trace files based on a session or client identifier or the service name, module name, and
prompt action name hierarchy combination. The output trace file from the trcsess command can then be
prompt sent to tkprof for a formatted output. Type trcsess at the command-line without any arguments to
prompt show the parameters and usage.
CLEAR COLUMNS BREAKS COMPUTES
COLUMN trace_type FORMAT a75 HEADING 'Trace Type' ENTMAP off
COLUMN primary_id FORMAT a75 HEADING 'Primary ID' ENTMAP off
COLUMN qualifier_id1 FORMAT a75 HEADING 'Module Name' ENTMAP off
COLUMN qualifier_id2 FORMAT a75 HEADING 'Action Name' ENTMAP off
COLUMN waits FORMAT a75 HEADING 'Waits?' ENTMAP off
COLUMN binds FORMAT a75 HEADING 'Binds?' ENTMAP off
COLUMN instance_name_print FORMAT a75 HEADING 'Instance Name' ENTMAP off
SELECT
'
, '
') || '
, '
') || '
, '
') || '
, '
, '
, '
') || '
FROM
dba_enabled_traces
ORDER BY
trace_type
, primary_id
, qualifier_id1
, qualifier_id2;
prompt
-- +----------------------------------------------------------------------------+
-- | - ENABLED AGGREGATIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Enabled Aggregations
prompt Statistics Aggregation from View DBA_ENABLED_AGGREGATIONS.
prompt
prompt
prompt
prompt Statistics aggregation is enabled using the DBMS_MONITOR package and the following procedures.
prompt Note that statistics gathering is global for the database and is persistent across instance starts
prompt and restarts.
prompt
prompt
prompt
prompt
prompt
prompt Hint: While the DBA_ENABLED_AGGREGATIONS provides global statistics for currently enabled
prompt statistics, several other views can be used to query statistics aggregation values: V$CLIENT_STATS,
prompt V$SERVICE_STATS, V$SERV_MOD_ACT_STATS, and V$SERVICEMETRIC.
CLEAR COLUMNS BREAKS COMPUTES
COLUMN aggregation_type FORMAT a75 HEADING 'Aggregation Type' ENTMAP off
COLUMN primary_id FORMAT a75 HEADING 'Primary ID' ENTMAP off
COLUMN qualifier_id1 FORMAT a75 HEADING 'Module Name' ENTMAP off
COLUMN qualifier_id2 FORMAT a75 HEADING 'Action Name' ENTMAP off
SELECT
'
, '
') || '
, '
') || '
, '
') || '
FROM
dba_enabled_aggregations
ORDER BY
aggregation_type
, primary_id
, qualifier_id1
, qualifier_id2;
prompt
-- +============================================================================+
-- | |
-- | <<<<< SECURITY >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - USER ACCOUNTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt User Accounts
CLEAR COLUMNS BREAKS COMPUTES
COLUMN username FORMAT a75 HEAD 'Username' ENTMAP off
COLUMN account_status FORMAT a75 HEAD 'Account Status' ENTMAP off
COLUMN expiry_date FORMAT a75 HEAD 'Expire Date' ENTMAP off
COLUMN default_tablespace FORMAT a75 HEAD 'Default Tbs.' ENTMAP off
COLUMN temporary_tablespace FORMAT a75 HEAD 'Temp Tbs.' ENTMAP off
COLUMN created FORMAT a75 HEAD 'Created On' ENTMAP off
COLUMN profile FORMAT a75 HEAD 'Profile' ENTMAP off
COLUMN sysdba FORMAT a75 HEAD 'SYSDBA' ENTMAP off
COLUMN sysoper FORMAT a75 HEAD 'SYSOPER' ENTMAP off
SELECT distinct
'' || a.username || '' username
, DECODE( a.account_status
, 'OPEN'
, '
, '
, '
') || '
, a.default_tablespace default_tablespace
, a.temporary_tablespace temporary_tablespace
, '
, a.profile profile
, '
') || '
, '
') || '
FROM
dba_users a
, v$pwfile_users p
WHERE
p.username (+) = a.username
ORDER BY
username;
prompt
-- +----------------------------------------------------------------------------+
-- | - USERS WITH DBA PRIVILEGES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Users With DBA Privileges
CLEAR COLUMNS BREAKS COMPUTES
COLUMN grantee FORMAT a70 HEADING 'Grantee' ENTMAP off
COLUMN granted_role FORMAT a35 HEADING 'Granted Role' ENTMAP off
COLUMN admin_option FORMAT a75 HEADING 'Admin. Option?' ENTMAP off
COLUMN default_role FORMAT a75 HEADING 'Default Role?' ENTMAP off
SELECT
'' || grantee || '' grantee
, '
, DECODE( admin_option
, 'YES'
, '
, 'NO'
, '
, '
, DECODE( default_role
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_role_privs
WHERE
granted_role = 'DBA'
ORDER BY
grantee
, granted_role;
prompt
-- +----------------------------------------------------------------------------+
-- | - ROLES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Roles
CLEAR COLUMNS BREAKS COMPUTES
COLUMN role FORMAT a70 HEAD 'Role Name' ENTMAP off
COLUMN grantee FORMAT a35 HEAD 'Grantee' ENTMAP off
COLUMN admin_option FORMAT a75 HEAD 'Admin Option?' ENTMAP off
COLUMN default_role FORMAT a75 HEAD 'Default Role?' ENTMAP off
BREAK ON role
SELECT
'' || b.role || '' role
, a.grantee grantee
, DECODE( a.admin_option
, null
, '
'
, 'YES'
, '
, 'NO'
, '
, '
, DECODE( a.default_role
, null
, '
'
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_role_privs a
, dba_roles b
WHERE
granted_role(+) = b.role
ORDER BY
b.role
, a.grantee;
prompt
-- +----------------------------------------------------------------------------+
-- | - DEFAULT PASSWORDS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Default Passwords
prompt User(s) with default password
CLEAR COLUMNS BREAKS COMPUTES
COLUMN username HEADING 'Username' ENTMAP off
COLUMN account_status FORMAT a75 HEADING 'Account Status' ENTMAP off
SELECT
'' || username || '' username
, DECODE( account_status
, 'OPEN'
, '
, '
FROM dba_users
WHERE password IN (
'E066D214D5421CCC' -- dbsnmp
, '24ABAB8B06281B4C' -- ctxsys
, '72979A94BAD2AF80' -- mdsys
, 'C252E8FA117AF049' -- odm
, 'A7A32CD03D3CE8D5' -- odm_mtr
, '88A2B2C183431F00' -- ordplugins
, '7EFA02EC7EA6B86F' -- ordsys
, '4A3BA55E08595C81' -- outln
, 'F894844C34402B67' -- scott
, '3F9FBD883D787341' -- wk_proxy
, '79DF7A1BD138CF11' -- wk_sys
, '7C9BA362F8314299' -- wmsys
, '88D8364765FCE6AF' -- xdb
, 'F9DA8977092B7B81' -- tracesvr
, '9300C0977D7DC75E' -- oas_public
, 'A97282CE3D94E29E' -- websys
, 'AC9700FD3F1410EB' -- lbacsys
, 'E7B5D92911C831E1' -- rman
, 'AC98877DE1297365' -- perfstat
, 'D4C5016086B2DC6A' -- sys
, 'D4DF7931AB130E37') -- system
ORDER BY
username;
prompt
-- +----------------------------------------------------------------------------+
-- | - DB LINKS - |
-- +----------------------------------------------------------------------------+
prompt
prompt DB Links
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN db_link FORMAT a75 HEADING 'DB Link Name' ENTMAP off
COLUMN username HEADING 'Username' ENTMAP off
COLUMN host HEADING 'Host' ENTMAP off
COLUMN created FORMAT a75 HEADING 'Created' ENTMAP off
BREAK ON owner
SELECT
'' || owner || '' owner
, db_link
, username
, host
, '
FROM dba_db_links
ORDER BY owner, db_link;
prompt
-- +============================================================================+
-- | |
-- | <<<<< OBJECTS >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - OBJECT SUMMARY - |
-- +----------------------------------------------------------------------------+
prompt
prompt Object Summary
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a60 HEADING 'Owner' ENTMAP off
COLUMN object_type FORMAT a25 HEADING 'Object Type' ENTMAP off
COLUMN obj_count FORMAT 999,999,999,999 HEADING 'Object Count' ENTMAP off
BREAK ON report ON owner SKIP 2
-- compute sum label "" of obj_count on owner
-- compute sum label 'Grand Total: ' of obj_count on report
COMPUTE sum LABEL 'Total: ' OF obj_count ON report
SELECT
'' || owner || '' owner
, object_type object_type
, count(*) obj_count
FROM
dba_objects
GROUP BY
owner
, object_type
ORDER BY
owner
, object_type;
prompt
-- +----------------------------------------------------------------------------+
-- | - SEGMENT SUMMARY - |
-- +----------------------------------------------------------------------------+
prompt
prompt Segment Summary
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a50 HEADING 'Owner' ENTMAP off
COLUMN segment_type FORMAT a25 HEADING 'Segment Type' ENTMAP off
COLUMN seg_count FORMAT 999,999,999,999 HEADING 'Segment Count' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in Bytes)' ENTMAP off
BREAK ON report ON owner SKIP 2
-- COMPUTE sum LABEL "" OF seg_count bytes ON owner
COMPUTE sum LABEL 'Total: ' OF seg_count bytes ON report
SELECT
'' || owner || '' owner
, segment_type segment_type
, count(*) seg_count
, sum(bytes) bytes
FROM
dba_segments
GROUP BY
owner
, segment_type
ORDER BY
owner
, segment_type;
prompt
-- +----------------------------------------------------------------------------+
-- | - TOP 100 SEGMENTS (BY SIZE) - |
-- +----------------------------------------------------------------------------+
prompt
prompt Top 100 Segments (by size)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner HEADING 'Owner' ENTMAP off
COLUMN segment_name HEADING 'Segment Name' ENTMAP off
COLUMN partition_name HEADING 'Partition Name' ENTMAP off
COLUMN segment_type HEADING 'Segment Type' ENTMAP off
COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP off
COLUMN extents FORMAT 999,999,999,999,999,999 HEADING 'Extents' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total: ' OF bytes extents ON report
SELECT
a.owner
, a.segment_name
, a.partition_name
, a.segment_type
, a.tablespace_name
, a.bytes
, a.extents
FROM
(select
b.owner
, b.segment_name
, b.partition_name
, b.segment_type
, b.tablespace_name
, b.bytes
, b.extents
from
dba_segments b
order by
b.bytes desc
) a
WHERE
rownum < 100;
prompt
-- +----------------------------------------------------------------------------+
-- | - TOP 100 SEGMENTS (BY EXTENTS) - |
-- +----------------------------------------------------------------------------+
prompt
prompt Top 100 Segments (by number of extents)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner HEADING 'Owner' ENTMAP off
COLUMN segment_name HEADING 'Segment Name' ENTMAP off
COLUMN partition_name HEADING 'Partition Name' ENTMAP off
COLUMN segment_type HEADING 'Segment Type' ENTMAP off
COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP off
COLUMN extents FORMAT 999,999,999,999,999,999 HEADING 'Extents' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP off
BREAK ON report
COMPUTE sum LABEL 'Total: ' OF extents bytes ON report
SELECT
a.owner
, a.segment_name
, a.partition_name
, a.segment_type
, a.tablespace_name
, a.extents
, a.bytes
FROM
(select
b.owner
, b.segment_name
, b.partition_name
, b.segment_type
, b.tablespace_name
, b.bytes
, b.extents
from
dba_segments b
order by
b.extents desc
) a
WHERE
rownum < 100;
prompt
-- +----------------------------------------------------------------------------+
-- | - DIRECTORIES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Directories
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN directory_name FORMAT a75 HEADING 'Directory Name' ENTMAP off
COLUMN directory_path HEADING 'Directory Path' ENTMAP off
BREAK ON report ON owner
SELECT
'
, '' || directory_name || '' directory_name
, '' || directory_path || '' directory_path
FROM
dba_directories
ORDER BY
owner
, directory_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - DIRECTORY PRIVILEGES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Directory Privileges
CLEAR COLUMNS BREAKS COMPUTES
COLUMN table_name FORMAT a75 HEADING 'Directory Name' ENTMAP off
COLUMN grantee FORMAT a75 HEADING 'Grantee' ENTMAP off
COLUMN privilege FORMAT a75 HEADING 'Privilege' ENTMAP off
COLUMN grantable FORMAT a75 HEADING 'Grantable?' ENTMAP off
BREAK ON report ON table_name ON grantee
SELECT
'' || table_name || '' table_name
, '' || grantee || '' grantee
, privilege privilege
, DECODE( grantable
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_tab_privs
WHERE
privilege IN ('READ', 'WRITE')
ORDER BY
table_name
, grantee
, privilege;
prompt
-- +----------------------------------------------------------------------------+
-- | - LIBRARIES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Libraries
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN library_name FORMAT a75 HEADING 'Library Name' ENTMAP off
COLUMN file_spec HEADING 'File Spec' ENTMAP off
COLUMN dynamic FORMAT a75 HEADING 'Dynamic?' ENTMAP off
COLUMN status FORMAT a75 HEADING 'Status' ENTMAP off
BREAK ON report ON owner
SELECT
'
, '' || library_name || '' library_name
, file_spec file_spec
, '
, DECODE( status
, 'VALID'
, '
, '
FROM
dba_libraries
ORDER BY
owner
, library_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - TYPES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Types
prompt Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN type_name FORMAT a75 HEADING 'Type Name' ENTMAP off
COLUMN typecode FORMAT a75 HEADING 'Type Code' ENTMAP off
COLUMN attributes FORMAT a75 HEADING 'Num. Attributes' ENTMAP off
COLUMN methods FORMAT a75 HEADING 'Num. Methods' ENTMAP off
COLUMN predefined FORMAT a75 HEADING 'Predefined?' ENTMAP off
COLUMN incomplete FORMAT a75 HEADING 'Incomplete?' ENTMAP off
COLUMN final FORMAT a75 HEADING 'Final?' ENTMAP off
COLUMN instantiable FORMAT a75 HEADING 'Instantiable?' ENTMAP off
COLUMN supertype_owner FORMAT a75 HEADING 'Super Owner' ENTMAP off
COLUMN supertype_name FORMAT a75 HEADING 'Super Name' ENTMAP off
COLUMN local_attributes FORMAT a75 HEADING 'Local Attributes' ENTMAP off
COLUMN local_methods FORMAT a75 HEADING 'Local Methods' ENTMAP off
BREAK ON report ON owner
SELECT
'
, '
, '
, '
, '
, '
, '
, '
, '
, '
') || '
, '
') || '
, '
') || '
, '
') || '
FROM
dba_types t
WHERE
t.owner NOT IN ( 'CTXSYS'
, 'DBSNMP'
, 'DMSYS'
, 'EXFSYS'
, 'IX'
, 'LBACSYS'
, 'MDSYS'
, 'OLAPSYS'
, 'ORDSYS'
, 'OUTLN'
, 'SYS'
, 'SYSMAN'
, 'SYSTEM'
, 'WKSYS'
, 'WMSYS'
, 'XDB')
ORDER BY
t.owner
, t.type_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - TYPE ATTRIBUTES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Type Attributes
prompt Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN type_name FORMAT a75 HEADING 'Type Name' ENTMAP off
COLUMN typecode FORMAT a75 HEADING 'Type Code' ENTMAP off
COLUMN attribute_name FORMAT a75 HEADING 'Attribute Name' ENTMAP off
COLUMN attribute_datatype FORMAT a75 HEADING 'Attribute Data Type' ENTMAP off
COLUMN inherited FORMAT a75 HEADING 'Inherited?' ENTMAP off
BREAK ON report ON owner ON type_name ON typecode
SELECT
'
, '
, '
, '
, (CASE
WHEN (a.length IS NOT NULL)
THEN a.attr_type_name || '(' || a.length || ')'
WHEN (a.attr_type_name='NUMBER' AND (a.precision IS NOT NULL AND a.scale IS NOT NULL))
THEN a.attr_type_name || '(' || a.precision || ',' || a.scale || ')'
WHEN (a.attr_type_name='NUMBER' AND (a.precision IS NOT NULL AND a.scale IS NULL))
THEN a.attr_type_name || '(' || a.precision || ')'
ELSE
a.attr_type_name
END) attribute_datatype
, DECODE( a.inherited
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_types t
, dba_type_attrs a
WHERE
t.owner = a.owner
AND t.type_name = a.type_name
AND t.owner NOT IN ( 'CTXSYS'
, 'DBSNMP'
, 'DMSYS'
, 'EXFSYS'
, 'IX'
, 'LBACSYS'
, 'MDSYS'
, 'OLAPSYS'
, 'ORDSYS'
, 'OUTLN'
, 'SYS'
, 'SYSMAN'
, 'SYSTEM'
, 'WKSYS'
, 'WMSYS'
, 'XDB')
ORDER BY
t.owner
, t.type_name
, t.typecode
, a.attr_no;
prompt
-- +----------------------------------------------------------------------------+
-- | - TYPE METHODS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Type Methods
prompt Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN type_name FORMAT a75 HEADING 'Type Name' ENTMAP off
COLUMN typecode FORMAT a75 HEADING 'Type Code' ENTMAP off
COLUMN method_name FORMAT a75 HEADING 'Method Name' ENTMAP off
COLUMN method_type FORMAT a75 HEADING 'Method Type' ENTMAP off
COLUMN num_parameters FORMAT a75 HEADING 'Num. Parameters' ENTMAP off
COLUMN results FORMAT a75 HEADING 'Results' ENTMAP off
COLUMN final FORMAT a75 HEADING 'Final?' ENTMAP off
COLUMN instantiable FORMAT a75 HEADING 'Instantiable?' ENTMAP off
COLUMN overriding FORMAT a75 HEADING 'Overriding?' ENTMAP off
COLUMN inherited FORMAT a75 HEADING 'Inherited?' ENTMAP off
BREAK ON report ON owner ON type_name ON typecode
SELECT
'
, '
, '
, '
, '
, '
, '
, '
, '
, '
, DECODE( m.inherited
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_types t
, dba_type_methods m
WHERE
t.owner = m.owner
AND t.type_name = m.type_name
AND t.owner NOT IN ( 'CTXSYS'
, 'DBSNMP'
, 'DMSYS'
, 'EXFSYS'
, 'IX'
, 'LBACSYS'
, 'MDSYS'
, 'OLAPSYS'
, 'ORDSYS'
, 'OUTLN'
, 'SYS'
, 'SYSMAN'
, 'SYSTEM'
, 'WKSYS'
, 'WMSYS'
, 'XDB')
ORDER BY
t.owner
, t.type_name
, t.typecode
, m.method_no;
prompt
-- +----------------------------------------------------------------------------+
-- | - COLLECTIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Collections
prompt Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN type_name FORMAT a75 HEADING 'Type Name' ENTMAP off
COLUMN coll_type FORMAT a75 HEADING 'Collection Type' ENTMAP off
COLUMN upper_bound FORMAT a75 HEADING 'VARRAY Limit' ENTMAP off
COLUMN elem_type_owner FORMAT a75 HEADING 'Element Type Owner' ENTMAP off
COLUMN elem_datatype FORMAT a75 HEADING 'Element Data Type' ENTMAP off
COLUMN character_set_name FORMAT a75 HEADING 'Character Set' ENTMAP off
COLUMN elem_storage FORMAT a75 HEADING 'Element Storage' ENTMAP off
COLUMN nulls_stored FORMAT a75 HEADING 'Nulls Stored?' ENTMAP off
BREAK ON report ON owner ON type_name
SELECT
'
, '
, '
, '
') || '
, '
') || '
, (CASE
WHEN (c.length IS NOT NULL)
THEN c.elem_type_name || '(' || c.length || ')'
WHEN (c.elem_type_name='NUMBER' AND (c.precision IS NOT NULL AND c.scale IS NOT NULL))
THEN c.elem_type_name || '(' || c.precision || ',' || c.scale || ')'
WHEN (c.elem_type_name='NUMBER' AND (c.precision IS NOT NULL AND c.scale IS NULL))
THEN c.elem_type_name || '(' || c.precision || ')'
ELSE
c.elem_type_name
END) elem_datatype
, '
') || '
, '
') || '
, DECODE( c.nulls_stored
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_coll_types c
WHERE
c.owner NOT IN ( 'CTXSYS'
, 'DBSNMP'
, 'DMSYS'
, 'EXFSYS'
, 'IX'
, 'LBACSYS'
, 'MDSYS'
, 'OLAPSYS'
, 'ORDSYS'
, 'OUTLN'
, 'SYS'
, 'SYSMAN'
, 'SYSTEM'
, 'WKSYS'
, 'WMSYS'
, 'XDB')
ORDER BY
c.owner
, c.type_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - LOB SEGMENTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt LOB Segments
prompt Excluding all internal system schemas (i.e. CTXSYS, MDSYS, SYS, SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a85 HEADING 'Owner' ENTMAP off
COLUMN table_name FORMAT a75 HEADING 'Table Name' ENTMAP off
COLUMN column_name FORMAT a75 HEADING 'Column Name' ENTMAP off
COLUMN segment_name FORMAT a125 HEADING 'LOB Segment Name' ENTMAP off
COLUMN tablespace_name FORMAT a75 HEADING 'Tablespace Name' ENTMAP off
COLUMN lob_segment_bytes FORMAT a75 HEADING 'Segment Size' ENTMAP off
COLUMN index_name FORMAT a125 HEADING 'LOB Index Name' ENTMAP off
COLUMN in_row FORMAT a75 HEADING 'In Row?' ENTMAP off
BREAK ON report ON owner ON table_name
SELECT
'
, '
, '
, '
, '
, '
, '
, DECODE( l.in_row
, 'YES'
, '
, 'NO'
, '
, '
FROM
dba_lobs l
, dba_segments s
WHERE
l.owner = s.owner
AND l.segment_name = s.segment_name
AND l.owner NOT IN ( 'CTXSYS'
, 'DBSNMP'
, 'DMSYS'
, 'EXFSYS'
, 'IX'
, 'LBACSYS'
, 'MDSYS'
, 'OLAPSYS'
, 'ORDSYS'
, 'OUTLN'
, 'SYS'
, 'SYSMAN'
, 'SYSTEM'
, 'WKSYS'
, 'WMSYS'
, 'XDB')
ORDER BY
l.owner
, l.table_name
, l.column_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - OBJECTS UNABLE TO EXTEND - |
-- +----------------------------------------------------------------------------+
prompt
prompt Objects Unable to Extend
prompt Segments that cannot extend because of MAXEXTENTS or not enough space
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN tablespace_name HEADING 'Tablespace Name' ENTMAP off
COLUMN segment_name HEADING 'Segment Name' ENTMAP off
COLUMN segment_type HEADING 'Segment Type' ENTMAP off
COLUMN next_extent FORMAT 999,999,999,999,999 HEADING 'Next Extent' ENTMAP off
COLUMN max FORMAT 999,999,999,999,999 HEADING 'Max. Piece Size' ENTMAP off
COLUMN sum FORMAT 999,999,999,999,999 HEADING 'Sum of Bytes' ENTMAP off
COLUMN extents FORMAT 999,999,999,999,999 HEADING 'Num. of Extents' ENTMAP off
COLUMN max_extents FORMAT 999,999,999,999,999 HEADING 'Max Extents' ENTMAP off
BREAK ON report ON owner
SELECT
'
, ds.tablespace_name tablespace_name
, ds.segment_name segment_name
, ds.segment_type segment_type
, ds.next_extent next_extent
, NVL(dfs.max, 0) max
, NVL(dfs.sum, 0) sum
, ds.extents extents
, ds.max_extents max_extents
FROM
dba_segments ds
, (select
max(bytes) max
, sum(bytes) sum
, tablespace_name
from
dba_free_space
group by
tablespace_name
) dfs
WHERE
(ds.next_extent > nvl(dfs.max, 0)
OR
ds.extents >= ds.max_extents)
AND ds.tablespace_name = dfs.tablespace_name (+)
AND ds.owner NOT IN ('SYS','SYSTEM')
ORDER BY
ds.owner
, ds.tablespace_name
, ds.segment_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - OBJECTS WHICH ARE NEARING MAXEXTENTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Objects Which Are Nearing MAXEXTENTS
prompt Segments where number of EXTENTS is less than 1/2 of MAXEXTENTS
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN tablespace_name FORMAT a30 HEADING 'Tablespace name' ENTMAP off
COLUMN segment_name FORMAT a30 HEADING 'Segment Name' ENTMAP off
COLUMN segment_type FORMAT a20 HEADING 'Segment Type' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Size (in bytes)' ENTMAP off
COLUMN next_extent FORMAT 999,999,999,999,999 HEADING 'Next Extent Size' ENTMAP off
COLUMN pct_increase HEADING '% Increase' ENTMAP off
COLUMN extents FORMAT 999,999,999,999,999 HEADING 'Num. of Extents' ENTMAP off
COLUMN max_extents FORMAT 999,999,999,999,999 HEADING 'Max Extents' ENTMAP off
COLUMN pct_util FORMAT a35 HEADING '% Utilized' ENTMAP off
SELECT
owner
, tablespace_name
, segment_name
, segment_type
, bytes
, next_extent
, pct_increase
, extents
, max_extents
, '
FROM
dba_segments
WHERE
extents > max_extents/2
AND max_extents != 0
ORDER BY
(extents/max_extents) DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - INVALID OBJECTS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Invalid Objects
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a85 HEADING 'Owner' ENTMAP off
COLUMN object_name FORMAT a30 HEADING 'Object Name' ENTMAP off
COLUMN object_type FORMAT a20 HEADING 'Object Type' ENTMAP off
COLUMN status FORMAT a75 HEADING 'Status' ENTMAP off
BREAK ON report ON owner
COMPUTE count LABEL 'Grand Total: ' OF object_name ON report
SELECT
'
, object_name
, object_type
, DECODE( status
, 'VALID'
, '
, '
FROM dba_objects
WHERE status <> 'VALID'
ORDER BY
owner
, object_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - PROCEDURAL OBJECT ERRORS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Procedural Object Errors
prompt All records from DBA_ERRORS
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a85 HEAD 'Schema' ENTMAP off
COLUMN name FORMAT a30 HEAD 'Object Name' ENTMAP off
COLUMN type FORMAT a15 HEAD 'Object Type' ENTMAP off
COLUMN sequence FORMAT 999,999 HEAD 'Sequence' ENTMAP off
COLUMN line FORMAT 999,999 HEAD 'Line' ENTMAP off
COLUMN position FORMAT 999,999 HEAD 'Position' ENTMAP off
COLUMN text HEAD 'Text' ENTMAP off
BREAK ON report ON owner
SELECT
'
, name
, type
, sequence
, line
, position
, text
FROM
dba_errors
ORDER BY
1
, 2
, 3;
prompt
-- +----------------------------------------------------------------------------+
-- | - OBJECTS WITHOUT STATISTICS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Objects Without Statistics
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a95 HEAD 'Owner' ENTMAP off
COLUMN object_type FORMAT a20 HEAD 'Object Type' ENTMAP off
COLUMN count FORMAT 999,999,999,999 HEAD 'Count' ENTMAP off
BREAK ON report ON owner
COMPUTE count LABEL 'Total: ' OF object_name ON report
SELECT
'
, 'Table' object_type
, count(*) count
FROM
sys.dba_tables
WHERE
last_analyzed IS NULL
AND owner NOT IN ('SYS','SYSTEM')
AND partitioned = 'NO'
GROUP BY
owner
, 'Table'
UNION
SELECT
'
, 'Index' object_type
, count(*) count
FROM
sys.dba_indexes
WHERE
last_analyzed IS NULL
AND owner NOT IN ('SYS','SYSTEM')
AND partitioned = 'NO'
GROUP BY
owner
, 'Index'
UNION
SELECT
'
, 'Table Partition' object_type
, count(*) count
FROM
sys.dba_tab_partitions
WHERE
last_analyzed IS NULL
AND table_owner NOT IN ('SYS','SYSTEM')
GROUP BY
table_owner
, 'Table Partition'
UNION
SELECT
'
, 'Index Partition' object_type
, count(*) count
FROM
sys.dba_ind_partitions
WHERE
last_analyzed IS NULL
AND index_owner NOT IN ('SYS','SYSTEM')
GROUP BY
index_owner
, 'Index Partition'
ORDER BY
1
, 2
, 3;
prompt
-- +----------------------------------------------------------------------------+
-- | - TABLES SUFFERING FROM ROW CHAINING/MIGRATION - |
-- +----------------------------------------------------------------------------+
prompt
prompt Tables Suffering From Row Chaining/Migration
prompt NOTE: Tables must have statistics gathered
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner HEADING 'Owner' ENTMAP off
COLUMN table_name HEADING 'Table Name' ENTMAP off
COLUMN partition_name HEADING 'Partition Name' ENTMAP off
COLUMN num_rows FORMAT 999,999,999,999,999 HEADING 'Total Rows' ENTMAP off
COLUMN pct_chained_rows FORMAT a65 HEADING '% Chained Rows' ENTMAP off
COLUMN avg_row_length FORMAT 999,999,999,999,999 HEADING 'Avg Row Length' ENTMAP off
SELECT
owner owner
, table_name table_name
, '' partition_name
, num_rows num_rows
, '
, avg_row_len avg_row_length
FROM
(select
owner
, table_name
, chain_cnt
, num_rows
, avg_row_len
from
sys.dba_tables
where
chain_cnt is not null
and num_rows is not null
and chain_cnt > 0
and num_rows > 0
and owner != 'SYS')
UNION ALL
SELECT
table_owner owner
, table_name table_name
, partition_name partition_name
, num_rows num_rows
, '
, avg_row_len avg_row_length
FROM
(select
table_owner
, table_name
, partition_name
, chain_cnt
, num_rows
, avg_row_len
from
sys.dba_tab_partitions
where
chain_cnt is not null
and num_rows is not null
and chain_cnt > 0
and num_rows > 0
and table_owner != 'SYS') b
WHERE
(chain_cnt/num_rows)*100 > 10;
prompt
-- +----------------------------------------------------------------------------+
-- | - USERS WITH DEFAULT TABLESPACE - (SYSTEM) - |
-- +----------------------------------------------------------------------------+
prompt
prompt Users With Default Tablespace - (SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN username FORMAT a75 HEADING 'Username' ENTMAP off
COLUMN default_tablespace FORMAT a125 HEADING 'Default Tablespace' ENTMAP off
COLUMN temporary_tablespace FORMAT a125 HEADING 'Temporary Tablespace' ENTMAP off
COLUMN created FORMAT a75 HEADING 'Created' ENTMAP off
COLUMN account_status FORMAT a75 HEADING 'Account Status' ENTMAP off
SELECT
'' || username || '' username
, '
, '
, '
, DECODE( account_status
, 'OPEN'
, '
, '
FROM
dba_users
WHERE
default_tablespace = 'SYSTEM'
ORDER BY
username;
prompt
-- +----------------------------------------------------------------------------+
-- | - USERS WITH DEFAULT TEMPORARY TABLESPACE - (SYSTEM) - |
-- +----------------------------------------------------------------------------+
prompt
prompt Users With Default Temporary Tablespace - (SYSTEM)
CLEAR COLUMNS BREAKS COMPUTES
COLUMN username FORMAT a75 HEADING 'Username' ENTMAP off
COLUMN default_tablespace FORMAT a125 HEADING 'Default Tablespace' ENTMAP off
COLUMN temporary_tablespace FORMAT a125 HEADING 'Temporary Tablespace' ENTMAP off
COLUMN created FORMAT a75 HEADING 'Created' ENTMAP off
COLUMN account_status FORMAT a75 HEADING 'Account Status' ENTMAP off
SELECT
'' || username || '' username
, '
, '
, '
, DECODE( account_status
, 'OPEN'
, '
, '
FROM
dba_users
WHERE
temporary_tablespace = 'SYSTEM'
ORDER BY
username;
prompt
-- +----------------------------------------------------------------------------+
-- | - OBJECTS IN THE SYSTEM TABLESPACE - |
-- +----------------------------------------------------------------------------+
prompt
prompt Objects in the SYSTEM Tablespace
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN segment_name FORMAT a125 HEADING 'Segment Name' ENTMAP off
COLUMN segment_type FORMAT a75 HEADING 'Type' ENTMAP off
COLUMN tablespace_name FORMAT a125 HEADING 'Tablespace' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Bytes|Alloc' ENTMAP off
COLUMN extents FORMAT 999,999,999,999,999 HEADING 'Extents' ENTMAP off
COLUMN max_extents FORMAT 999,999,999,999,999 HEADING 'Max|Ext' ENTMAP off
COLUMN initial_extent FORMAT 999,999,999,999,999 HEADING 'Initial|Ext' ENTMAP off
COLUMN next_extent FORMAT 999,999,999,999,999 HEADING 'Next|Ext' ENTMAP off
COLUMN pct_increase FORMAT 999,999,999,999,999 HEADING 'Pct|Inc' ENTMAP off
BREAK ON report ON owner
COMPUTE count LABEL 'Total Count: ' OF segment_name ON report
COMPUTE sum LABEL 'Total Bytes: ' OF bytes ON report
SELECT
'
, segment_name
, segment_type
, tablespace_name
, bytes
, extents
, initial_extent
, next_extent
, pct_increase
FROM
dba_segments
WHERE
owner NOT IN ('SYS','SYSTEM')
AND tablespace_name = 'SYSTEM'
ORDER BY
owner
, segment_name
, extents DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - RECYCLE BIN - |
-- +----------------------------------------------------------------------------+
prompt
prompt Recycle Bin
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a85 HEADING 'Owner' ENTMAP off
COLUMN original_name HEADING 'Original|Name' ENTMAP off
COLUMN type HEADING 'Object|Type' ENTMAP off
COLUMN object_name HEADING 'Object|Name' ENTMAP off
COLUMN ts_name HEADING 'Tablespace' ENTMAP off
COLUMN operation HEADING 'Operation' ENTMAP off
COLUMN createtime HEADING 'Create|Time' ENTMAP off
COLUMN droptime HEADING 'Drop|Time' ENTMAP off
COLUMN can_undrop HEADING 'Can|Undrop?' ENTMAP off
COLUMN can_purge HEADING 'Can|Purge?' ENTMAP off
COLUMN bytes FORMAT 999,999,999,999,999 HEADING 'Bytes' ENTMAP off
BREAK ON report ON owner
SELECT
'
, original_name
, type
, object_name
, ts_name
, operation
, '
') || '
, '
') || '
, DECODE( can_undrop
, null
, '
'
, 'YES'
, '
, 'NO'
, '
, '
, DECODE( can_purge
, null
, '
'
, 'YES'
, '
, 'NO'
, '
, '
, (space * p.blocksize) bytes
FROM
dba_recyclebin r
, (SELECT value blocksize FROM v$parameter WHERE name='db_block_size') p
ORDER BY
owner
, object_name;
prompt
-- +============================================================================+
-- | |
-- | <<<<< ONLINE ANALYTICAL PROCESSING - (OLAP) >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - DIMENSIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Dimensions
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN dimension_name FORMAT a75 HEADING 'Dimension Name' ENTMAP off
COLUMN invalid FORMAT a75 HEADING 'Invalid?' ENTMAP off
COLUMN compile_state FORMAT a75 HEADING 'Compile State' ENTMAP off
COLUMN revision HEADING 'Revision' ENTMAP off
BREAK ON report ON owner
SELECT
'
, dd.dimension_name dimension_name
, '
, DECODE( dd.compile_state
, 'VALID'
, '
, '
, '
FROM
dba_dimensions dd
ORDER BY
dd.owner
, dd.dimension_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - DIMENSION LEVELS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Dimension Levels
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN dimension_name FORMAT a75 HEADING 'Dimension Name' ENTMAP off
COLUMN level_name FORMAT a75 HEADING 'Level Name' ENTMAP off
COLUMN level_table_name FORMAT a75 HEADING 'Source Table' ENTMAP off
COLUMN column_name FORMAT a75 HEADING 'Column Name(s)' ENTMAP off
COLUMN key_position FORMAT a75 HEADING 'Column Position' ENTMAP off
BREAK ON owner ON dimension_name ON level_name ON level_table_name
SELECT
'
, d.dimension_name dimension_name
, l.level_name level_name
, l.detailobj_owner || '.' || l.detailobj_name level_table_name
, k.column_name column_name
, '
FROM
dba_dimensions d
, dba_dim_levels l
, dba_dim_level_key k
WHERE
d.owner = l.owner
AND d.dimension_name = l.dimension_name
AND d.owner = k.owner
AND d.dimension_name = k.dimension_name
AND l.level_name = k.level_name
ORDER by
l.owner
, l.dimension_name
, l.level_name
, level_table_name
, k.key_position;
prompt
-- +----------------------------------------------------------------------------+
-- | - DIMENSION ATTRIBUTES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Dimension Attributes
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN dimension_name FORMAT a75 HEADING 'Dimension Name' ENTMAP off
COLUMN level_name FORMAT a75 HEADING 'Level Name' ENTMAP off
COLUMN level_table_name FORMAT a75 HEADING 'Source Table' ENTMAP off
COLUMN column_name FORMAT a75 HEADING 'Attribute Source Column' ENTMAP off
COLUMN inferred FORMAT a75 HEADING 'Inferred?' ENTMAP off
BREAK ON report ON owner ON dimension_name ON level_name
SELECT
'
, d.dimension_name dimension_name
, l.level_name level_name
, l.detailobj_owner || '.' || l.detailobj_name level_table_name
, a.column_name column_name
, '
FROM
dba_dimensions d
, dba_dim_levels l
, dba_dim_attributes a
WHERE
d.owner = l.owner
AND d.dimension_name = l.dimension_name
AND d.owner = a.owner
AND d.dimension_name = a.dimension_name
AND l.level_name = a.level_name
ORDER by
l.owner
, l.dimension_name
, l.level_name
, level_table_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - DIMENSION HIERARCHIES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Dimension Hierarchies
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN dimension_name FORMAT a75 HEADING 'Dimension Name' ENTMAP off
COLUMN hierarchy_name FORMAT a75 HEADING 'Hierarchy Name' ENTMAP off
COLUMN parent_level_name FORMAT a75 HEADING 'Parent Level' ENTMAP off
COLUMN child_level_name FORMAT a75 HEADING 'Child Level' ENTMAP off
COLUMN position FORMAT a75 HEADING 'Position' ENTMAP off
COLUMN join_key_id FORMAT a75 HEADING 'Join Key ID' ENTMAP off
BREAK ON owner ON dimension_name ON hierarchy_name
SELECT
'
, d.dimension_name dimension_name
, h.hierarchy_name hierarchy_name
, c.parent_level_name parent_level_name
, c.child_level_name child_level_name
, '
, '
') || '
FROM
dba_dimensions d
, dba_dim_hierarchies h
, dba_dim_child_of c
WHERE
d.owner = h.owner
AND d.dimension_name = h.dimension_name
AND d.owner = c.owner
AND d.dimension_name = c.dimension_name
AND h.hierarchy_name = c.hierarchy_name
ORDER BY
d.owner
, d.dimension_name
, h.hierarchy_name
, c.position DESC;
prompt
-- +----------------------------------------------------------------------------+
-- | - CUBES - |
-- +----------------------------------------------------------------------------+
prompt
prompt Cubes
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN cube_name FORMAT a75 HEADING 'Cube Name' ENTMAP off
COLUMN invalid FORMAT a75 HEADING 'Valid?' ENTMAP off
COLUMN display_name FORMAT a75 HEADING 'Display Name' ENTMAP off
COLUMN description FORMAT a275 HEADING 'Description' ENTMAP off
BREAK ON report ON owner
SELECT
'
, c.cube_name cube_name
, DECODE( c.invalid
, 'O'
, '
, '1'
, '
, 'Y'
, '
, 'N'
, '
, '
, c.display_name display_name
, REPLACE(REPLACE(c.description, '<', '\<'), '>', '\>') description
FROM
dba_olap_cubes c
ORDER BY
c.owner
, c.cube_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - MATERIALIZED VIEWS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Materialized Views
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN mview_name FORMAT a75 HEADING 'MView|Name' ENTMAP off
COLUMN master_link FORMAT a75 HEADING 'Master|Link' ENTMAP off
COLUMN updatable FORMAT a75 HEADING 'Updatable?' ENTMAP off
COLUMN update_log FORMAT a75 HEADING 'Update|Log' ENTMAP off
COLUMN rewrite_enabled FORMAT a75 HEADING 'Rewrite|Enabled?' ENTMAP off
COLUMN refresh_mode FORMAT a75 HEADING 'Refresh|Mode' ENTMAP off
COLUMN refresh_method FORMAT a75 HEADING 'Refresh|Method' ENTMAP off
COLUMN build_mode FORMAT a75 HEADING 'Build|Mode' ENTMAP off
COLUMN fast_refreshable FORMAT a75 HEADING 'Fast|Refreshable' ENTMAP off
COLUMN last_refresh_type FORMAT a75 HEADING 'Last Refresh|Type' ENTMAP off
COLUMN last_refresh_date FORMAT a75 HEADING 'Last Refresh|Date' ENTMAP off
COLUMN staleness FORMAT a75 HEADING 'Staleness' ENTMAP off
COLUMN compile_state FORMAT a75 HEADING 'Compile State' ENTMAP off
BREAK ON owner
SELECT
'
, m.mview_name mview_name
, m.master_link master_link
, '
') || '
, update_log update_log
, '
') || '
, m.refresh_mode refresh_mode
, m.refresh_method refresh_method
, m.build_mode build_mode
, m.fast_refreshable fast_refreshable
, m.last_refresh_type last_refresh_type
, '
, m.staleness staleness
, DECODE( m.compile_state
, 'VALID'
, '
, '
FROM
dba_mviews m
ORDER BY
owner
, mview_name
/
prompt
-- +----------------------------------------------------------------------------+
-- | - MATERIALIZED VIEW LOGS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Materialized View Logs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN log_owner FORMAT a75 HEADING 'Log Owner' ENTMAP off
COLUMN log_table FORMAT a75 HEADING 'Log Table' ENTMAP off
COLUMN master FORMAT a75 HEADING 'Master' ENTMAP off
COLUMN log_trigger FORMAT a75 HEADING 'Log Trigger' ENTMAP off
COLUMN rowids FORMAT a75 HEADING 'Rowids?' ENTMAP off
COLUMN primary_key FORMAT a75 HEADING 'Primary Key?' ENTMAP off
COLUMN object_id FORMAT a75 HEADING 'Object ID?' ENTMAP off
COLUMN filter_columns FORMAT a75 HEADING 'Filter Columns?' ENTMAP off
COLUMN sequence FORMAT a75 HEADING 'Sequence?' ENTMAP off
COLUMN include_new_values FORMAT a75 HEADING 'Include New Values?' ENTMAP off
BREAK ON log_owner
SELECT
'
, ml.log_table log_table
, ml.master master
, ml.log_trigger log_trigger
, '
') || '
, '
') || '
, '
') || '
, '
') || '
, '
') || '
, '
') || '
FROM
dba_mview_logs ml
ORDER BY
ml.log_owner
, ml.master;
prompt
-- +----------------------------------------------------------------------------+
-- | - MATERIALIZED VIEW REFRESH GROUPS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Materialized View Refresh Groups
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN name FORMAT a75 HEADING 'Name' ENTMAP off
COLUMN broken FORMAT a75 HEADING 'Broken?' ENTMAP off
COLUMN next_date FORMAT a75 HEADING 'Next Date' ENTMAP off
COLUMN interval FORMAT a75 HEADING 'Interval' ENTMAP off
BREAK ON report ON owner
SELECT
'
, '
, '
, '
') || '
, '
FROM
dba_refresh
ORDER BY
rowner
, rname
/
prompt
-- +============================================================================+
-- | |
-- | <<<<< DATA PUMP >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - DATA PUMP JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Data Pump Jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner_name FORMAT a75 HEADING 'Owner Name' ENTMAP off
COLUMN job_name FORMAT a75 HEADING 'Job Name' ENTMAP off
COLUMN operation FORMAT a75 HEADING 'Operation' ENTMAP off
COLUMN job_mode FORMAT a75 HEADING 'Job Mode' ENTMAP off
COLUMN state FORMAT a75 HEADING 'State' ENTMAP off
COLUMN degree FORMAT 999,999,999 HEADING 'Degree' ENTMAP off
COLUMN attached_sessions FORMAT 999,999,999 HEADING 'Attached Sessions' ENTMAP off
SELECT
'
, dpj.job_name job_name
, dpj.operation operation
, dpj.job_mode job_mode
, dpj.state state
, dpj.degree degree
, dpj.attached_sessions attached_sessions
FROM
dba_datapump_jobs dpj
ORDER BY
dpj.owner_name
, dpj.job_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - DATA PUMP SESSIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Data Pump Sessions
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a75 HEADING 'Instance Name' ENTMAP off
COLUMN owner_name FORMAT a75 HEADING 'Owner Name' ENTMAP off
COLUMN job_name FORMAT a75 HEADING 'Job Name' ENTMAP off
COLUMN session_type FORMAT a75 HEADING 'Session Type' ENTMAP off
COLUMN sid HEADING 'SID' ENTMAP off
COLUMN serial_no HEADING 'Serial#' ENTMAP off
COLUMN oracle_username FORMAT a75 HEADING 'Oracle Username' ENTMAP off
COLUMN os_username FORMAT a75 HEADING 'O/S Username' ENTMAP off
COLUMN os_pid HEADING 'O/S PID' ENTMAP off
BREAK ON report ON instance_name_print ON owner_name ON job_name
SELECT
'
, dj.owner_name owner_name
, dj.job_name job_name
, ds.type session_type
, s.sid sid
, s.serial# serial_no
, s.username oracle_username
, s.osuser os_username
, p.spid os_pid
FROM
gv$datapump_job dj
, gv$datapump_session ds
, gv$session s
, gv$instance i
, gv$process p
WHERE
s.inst_id = i.inst_id
AND s.inst_id = p.inst_id
AND ds.inst_id = i.inst_id
AND dj.inst_id = i.inst_id
AND s.saddr = ds.saddr
AND s.paddr = p.addr (+)
AND dj.job_id = ds.job_id
ORDER BY
i.instance_name
, dj.owner_name
, dj.job_name
, ds.type;
prompt
-- +----------------------------------------------------------------------------+
-- | - DATA PUMP JOB PROGRESS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Data Pump Job Progress
CLEAR COLUMNS BREAKS COMPUTES
COLUMN instance_name_print FORMAT a75 HEADING 'Instance Name' ENTMAP off
COLUMN owner_name FORMAT a75 HEADING 'Owner Name' ENTMAP off
COLUMN job_name FORMAT a75 HEADING 'Job Name' ENTMAP off
COLUMN session_type FORMAT a75 HEADING 'Session Type' ENTMAP off
COLUMN start_time HEADING 'Start Time' ENTMAP off
COLUMN time_remaining FORMAT 9,999,999,999,999 HEADING 'Time Remaining (min.)' ENTMAP off
COLUMN sofar FORMAT 9,999,999,999,999 HEADING 'Bytes Completed So Far' ENTMAP off
COLUMN totalwork FORMAT 9,999,999,999,999 HEADING 'Total Bytes for Job' ENTMAP off
COLUMN pct_completed HEADING '% Completed' ENTMAP off
BREAK ON report ON instance_name_print ON owner_name ON job_name
SELECT
'
, dj.owner_name owner_name
, dj.job_name job_name
, ds.type session_type
, '
, ROUND(sl.time_remaining/60,0) time_remaining
, sl.sofar sofar
, sl.totalwork totalwork
, '
FROM
gv$datapump_job dj
, gv$datapump_session ds
, gv$session s
, gv$instance i
, gv$session_longops sl
WHERE
s.inst_id = i.inst_id
AND ds.inst_id = i.inst_id
AND dj.inst_id = i.inst_id
AND sl.inst_id = i.inst_id
AND s.saddr = ds.saddr
AND dj.job_id = ds.job_id
AND sl.sid = s.sid
AND sl.serial# = s.serial#
AND ds.type = 'MASTER'
ORDER BY
i.instance_name
, dj.owner_name
, dj.job_name
, ds.type;
prompt
-- +============================================================================+
-- | |
-- | <<<<< NETWORKING >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - MTS DISPATCHER STATISTICS - |
-- +----------------------------------------------------------------------------+
prompt
prompt MTS Dispatcher Statistics
prompt Dispatcher rate
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name HEADING 'Name' ENTMAP off
COLUMN avg_loop_rate HEADING 'Avg|Loop|Rate' ENTMAP off
COLUMN avg_event_rate HEADING 'Avg|Event|Rate' ENTMAP off
COLUMN avg_events_per_loop HEADING 'Avg|Events|Per|Loop' ENTMAP off
COLUMN avg_msg_rate HEADING 'Avg|Msg|Rate' ENTMAP off
COLUMN avg_svr_buf_rate HEADING 'Avg|Svr|Buf|Rate' ENTMAP off
COLUMN avg_svr_byte_rate HEADING 'Avg|Svr|Byte|Rate' ENTMAP off
COLUMN avg_svr_byte_per_buf HEADING 'Avg|Svr|Byte|Per|Buf' ENTMAP off
COLUMN avg_clt_buf_rate HEADING 'Avg|Clt|Buf|Rate' ENTMAP off
COLUMN avg_clt_byte_rate HEADING 'Avg|Clt|Byte|Rate' ENTMAP off
COLUMN avg_clt_byte_per_buf HEADING 'Avg|Clt|Byte|Per|Buf' ENTMAP off
COLUMN avg_buf_rate HEADING 'Avg|Buf|Rate' ENTMAP off
COLUMN avg_byte_rate HEADING 'Avg|Byte|Rate' ENTMAP off
COLUMN avg_byte_per_buf HEADING 'Avg|Byte|Per|Buf' ENTMAP off
COLUMN avg_in_connect_rate HEADING 'Avg|In|Connect|Rate' ENTMAP off
COLUMN avg_out_connect_rate HEADING 'Avg|Out|Connect|Rate' ENTMAP off
COLUMN avg_reconnect_rate HEADING 'Avg|Reconnect|Rate' ENTMAP off
SELECT
name
, avg_loop_rate
, avg_event_rate
, avg_events_per_loop
, avg_msg_rate
, avg_svr_buf_rate
, avg_svr_byte_rate
, avg_svr_byte_per_buf
, avg_clt_buf_rate
, avg_clt_byte_rate
, avg_clt_byte_per_buf
, avg_buf_rate
, avg_byte_rate
, avg_byte_per_buf
, avg_in_connect_rate
, avg_out_connect_rate
, avg_reconnect_rate
FROM
v$dispatcher_rate
ORDER BY
name;
COLUMN protocol HEADING 'Protocol' ENTMAP off
COLUMN total_busy_rate HEADING 'Total Busy Rate' ENTMAP off
prompt Dispatcher busy rate
SELECT
a.network protocol
, (SUM(a.BUSY) / (SUM(a.BUSY) + SUM(a.IDLE))) total_busy_rate
FROM
v$dispatcher a
GROUP BY
a.network;
prompt
-- +----------------------------------------------------------------------------+
-- | - MTS DISPATCHER RESPONSE QUEUE WAIT STATS - |
-- +----------------------------------------------------------------------------+
prompt
prompt MTS Dispatcher Response Queue Wait Stats
CLEAR COLUMNS BREAKS COMPUTES
COLUMN type HEADING 'Type' ENTMAP off
COLUMN avg_wait HEADING 'Avg Wait Time Per Response' ENTMAP off
SELECT
a.type
, DECODE( SUM(a.totalq), 0, 'NO RESPONSES', SUM(a.wait)/SUM(a.totalq) || ' HUNDREDTHS OF SECONDS') avg_wait
FROM
v$queue a
WHERE
a.type='DISPATCHER'
GROUP BY
a.type;
prompt
-- +----------------------------------------------------------------------------+
-- | - MTS SHARED SERVER WAIT STATISTICS - |
-- +----------------------------------------------------------------------------+
prompt
prompt MTS Shared Server Wait Statistics
CLEAR COLUMNS BREAKS COMPUTES
COLUMN avg_wait HEADING 'Average Wait Time Per Request' ENTMAP off
SELECT
DECODE(a.totalq, 0, 'No Requests', a.wait/a.totalq || ' HUNDREDTHS OF SECONDS') avg_wait
FROM
v$queue a
WHERE
a.type='COMMON';
prompt
-- +============================================================================+
-- | |
-- | <<<<< REPLICATION >>>>> |
-- | |
-- +============================================================================+
prompt
prompt
-- +----------------------------------------------------------------------------+
-- | - REPLICATION SUMMARY - |
-- +----------------------------------------------------------------------------+
prompt
prompt Replication Summary
CLEAR COLUMNS BREAKS COMPUTES
COLUMN gname HEADING 'Current Database Name' ENTMAP off
COLUMN admin_request HEADING '# Admin. Requests' ENTMAP off
COLUMN status HEADING '# Admin. Request Errors' ENTMAP off
COLUMN df_txn HEADING '# Def. Trans' ENTMAP off
COLUMN df_error HEADING '# Def. Tran Errors' ENTMAP off
COLUMN complete HEADING '# Complete Trans in Queue' ENTMAP off
SELECT
g.global_name gname
, d.admin_request admin_request
, e.status status
, dt.tran df_txn
, de.error df_error
, c.complete complete
FROM
(select global_name from global_name) g
, (select count(id) admin_request
from sys.dba_repcatlog) d
, (select count(status) status
from sys.dba_repcatlog
where status = 'ERROR') e
, (select count(*) tran
from deftrandest) dt
, (select count(*) error
from deferror) de
, (select count(a.deferred_tran_id) complete
from deftran a
where a.deferred_tran_id not in
(select b.deferred_tran_id
from deftrandest b)
) c
/
prompt
-- +----------------------------------------------------------------------------+
-- | - DEFERRED TRANSACTIONS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Deferred Transactions
CLEAR COLUMNS BREAKS COMPUTES
COLUMN source HEADING 'Source' ENTMAP off
COLUMN dest HEADING 'Target' ENTMAP off
COLUMN trans HEADING '# Def. Trans' ENTMAP off
COLUMN errors HEADING '# Def. Tran Errors' ENTMAP off
SELECT
source
, dest
, trans
, errors
FROM
(select
e.origin_tran_db source
, e.destination dest
, 'n/a' trans
, to_char(count(*)) errors
from
deferror e
group by
e.origin_tran_db
, e.destination
union
select
g.global_name source
, d.dblink dest
, to_char(count(*)) trans
, 'n/a' errors
from
(select global_name from global_name) g
, deftran t
, deftrandest d
where
d.deferred_tran_id = t.deferred_tran_id
group by
g.global_name, d.dblink
);
prompt
-- +----------------------------------------------------------------------------+
-- | - ADMINISTRATIVE REQUEST JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Administrative Request Jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN job HEADING 'Job ID' ENTMAP off
COLUMN priv_user HEADING 'Privilege Schema' ENTMAP off
COLUMN what FORMAT a175 HEADING 'Definition' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN next_date FORMAT a75 HEADING 'Start' ENTMAP off
COLUMN interval HEADING 'Interval' ENTMAP off
SELECT
job job
, priv_user priv_user
, what what
, DECODE(broken, 'Y', 'Broken', 'Normal') status
, '
') || '
, interval
FROM
sys.dba_jobs
WHERE
what LIKE '%dbms_repcat.do_deferred_repcat_admin%'
ORDER BY
1;
prompt
-- +----------------------------------------------------------------------------+
-- | - INITIALIZATION PARAMETERS - |
-- +----------------------------------------------------------------------------+
prompt
prompt Initialization Parameters
CLEAR COLUMNS BREAKS COMPUTES
COLUMN pname FORMAT a55 HEADING 'Parameter Name' ENTMAP off
COLUMN value FORMAT a55 HEADING 'Value' ENTMAP off
COLUMN isdefault FORMAT a55 HEADING 'Is Default?' ENTMAP off
COLUMN issys_modifiable FORMAT a55 HEADING 'Is Dynamic?' ENTMAP off
SELECT
DECODE( isdefault
, 'FALSE'
, '' || SUBSTR(name,0,512) || ''
, '' || SUBSTR(name,0,512) || '' ) pname
, DECODE( isdefault
, 'FALSE'
, '' || SUBSTR(value,0,512) || ''
, SUBSTR(value,0,512) ) value
, DECODE( isdefault
, 'FALSE'
, '
, '
, DECODE( isdefault
, 'FALSE'
, '
, '
FROM
v$parameter
WHERE
name IN ( 'compatible'
, 'commit_point_strength'
, 'dblink_encrypt_login'
, 'distributed_lock_timeout'
, 'distributed_recovery_connection_hold_time'
, 'distributed_transactions'
, 'global_names'
, 'job_queue_interval'
, 'job_queue_processes'
, 'max_transaction_branches'
, 'open_links'
, 'open_links_per_instance'
, 'parallel_automatic_tuning'
, 'parallel_max_servers'
, 'parallel_min_servers'
, 'parallel_server_idle_time'
, 'processes'
, 'remote_dependencies_mode'
, 'replication_dependency_tracking'
, 'shared_pool_size'
, 'utl_file_dir'
)
ORDER BY name;
prompt
-- +----------------------------------------------------------------------------+
-- | - (SCHEDULE) - PURGE JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Schedule) - Purge Jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN job HEADING 'Job ID' ENTMAP off
COLUMN priv_user HEADING 'Privilege Schema' ENTMAP off
COLUMN status HEADING 'Status' ENTMAP off
COLUMN next_date FORMAT a75 HEADING 'Start' ENTMAP off
COLUMN interval HEADING 'Interval' ENTMAP off
SELECT
j.job job
, j.priv_user priv_user
, decode(broken, 'Y', 'Broken', 'Normal') status
, '
') || '
, s.interval interval
FROM
sys.defschedule s
, sys.dba_jobs j
WHERE
s.dblink = (select global_name from global_name)
AND s.interval is not null AND s.job = j.job
ORDER BY
1;
prompt
-- +----------------------------------------------------------------------------+
-- | - (SCHEDULE) - PUSH JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Schedule) - Push Jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN job HEADING 'Job ID' ENTMAP off
COLUMN priv_user HEADING 'Privilege Schema' ENTMAP off
COLUMN dblink HEADING 'Target' ENTMAP off
COLUMN broken HEADING 'Status' ENTMAP off
COLUMN next_date FORMAT a75 HEADING 'Start' ENTMAP off
COLUMN interval HEADING 'Interval' ENTMAP off
SELECT
j.job job
, j.priv_user priv_user
, s.dblink dblink
, decode(j.broken, 'Y', 'Broken', 'Normal') broken
, '
') || '
, s.interval interval
FROM
sys.defschedule s
, sys.dba_jobs j
WHERE
s.dblink != (select global_name from global_name)
AND s.interval is not null
AND s.job = j.job
ORDER BY
1;
prompt
-- +----------------------------------------------------------------------------+
-- | - (SCHEDULE) - REFRESH JOBS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Schedule) - Refresh Jobs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN job HEADING 'Job ID' ENTMAP off
COLUMN priv_user HEADING 'Privilege Schema' ENTMAP off
COLUMN refresh_group HEADING 'Refresh Group' ENTMAP off
COLUMN broken HEADING 'Status' ENTMAP off
COLUMN next_date FORMAT a75 HEADING 'Start' ENTMAP off
COLUMN interval FORMAT a75 HEADING 'Interval' ENTMAP off
SELECT
j.job job
, j.priv_user priv_user
, r.rowner || '.' || r.rname refresh_group
, decode(j.broken, 'Y', 'Broken', 'Normal') broken
, '
') || '
, '
FROM
sys.dba_refresh r
, sys.dba_jobs j
WHERE
r.job = j.job
order by
1;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MULTI-MASTER) - MASTER GROUPS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Multi-Master) - Master Groups
CLEAR COLUMNS BREAKS COMPUTES
COLUMN name HEADING 'Master Group' ENTMAP off
COLUMN num_def_trans HEADING '# Def. Trans' ENTMAP off
COLUMN num_tran_errors HEADING '# Def. Tran Errors' ENTMAP off
COLUMN num_admin_requests HEADING '# Admin. Requests' ENTMAP off
COLUMN num_admin_request_errors HEADING '# Admin. Request Errors' ENTMAP off
SELECT
g.gname name
, NVL(t.cnt1, 0) num_def_trans
, NVL(ie.cnt2, 0) num_tran_errors
, NVL(a.cnt3, 0) num_admin_requests
, NVL(b.cnt4, 0) num_admin_request_errors
FROM
(select distinct gname
from dba_repgroup
where master='Y') g
, (select
rog rog
, count(dt.deferred_tran_id) cnt1
from (select distinct
ro.gname rog
, d.deferred_tran_id dft
from
dba_repobject ro
, defcall d
, deftrANDest td
where
ro.sname = d.schemaname
AND ro.oname = d.packagename
AND ro.type in ('TABLE', 'PACKAGE', 'SNAPSHOT')
AND td.deferred_tran_id = d.deferred_tran_id
) t0, deftrANDest dt
where
dt.deferred_tran_id = dft
group by rog
) t
, (select distinct
ro.gname
, count(distinct e.deferred_tran_id) cnt2
from
dba_repobject ro
, defcall d
, deferror e
where
ro.sname = d.schemaname
AND ro.oname = d.packagename
AND ro.type in ('TABLE', 'PACKAGE', 'SNAPSHOT')
AND e.deferred_tran_id = d.deferred_tran_id
AND e.callno = d.callno
group by ro.gname
) ie
, (select gname, count(*) cnt3
from dba_repcatlog
group by gname
) a
, (select gname, count(*) cnt4
from dba_repcatlog
where status = 'ERROR'
group BY gname
) b
WHERE
g.gname = ie.gname (+)
AND g.gname = t.rog (+)
AND g.gname = a.gname (+)
AND g.gname = b.gname (+)
ORDER BY
g.gname;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MULTI-MASTER) - MASTER GROUPS AND SITES - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Multi-Master) - Master Groups and Sites
CLEAR COLUMNS BREAKS COMPUTES
COLUMN master_group HEADING 'Master Group' ENTMAP off
COLUMN sites HEADING 'Sites' ENTMAP off
COLUMN master_definition_site HEADING 'Master Definition Site' ENTMAP off
SELECT
gname master_group
, dblink sites
, DECODE(masterdef, 'Y', 'YES', 'N', 'NO') master_definition_site
FROM
sys.dba_repsites
WHERE
master = 'Y'
AND gname NOT IN (
SELECT gname from sys.dba_repsites
WHERE snapmaster = 'Y'
)
ORDER BY
gname;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - MASTER SITE SUMMARY - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Master Site Summary
CLEAR COLUMNS BREAKS COMPUTES
COLUMN mgroup HEADING '# of Master Groups' ENTMAP off
COLUMN mvgroup HEADING '# of Registered MV Groups' ENTMAP off
COLUMN mv HEADING '# of Registered MVs' ENTMAP off
COLUMN mvlog HEADING '# of MV Logs' ENTMAP off
COLUMN template HEADING '# of Templates' ENTMAP off
SELECT
a.mgroup mgroup
, b.mvgroup mvgroup
, c.mv mv
, d.mvlog mvlog
, e.template template
FROM
(select count(g.gname) mgroup
from sys.dba_repgroup g, sys.dba_repsites s
where g.master = 'Y'
and s.master = 'Y'
and g.gname = s.gname
and s.my_dblink = 'Y') a
, (select count(*) mvGROUP
from sys.dba_registered_snapshot_groups) b
, (select count(*) mv
from sys.dba_registered_snapshots) c
, (select count(*) mvlog
from sys.dba_snapshot_logs) d
, (select count(*) template
from sys.dba_repcat_refresh_templates) e;
CLEAR COLUMNS BREAKS COMPUTES
COLUMN log_owner FORMAT a75 HEADING 'Log Owner' ENTMAP off
COLUMN log_table HEADING 'Log Table' ENTMAP off
COLUMN master HEADING 'Master' ENTMAP off
COLUMN rowids FORMAT a75 HEADING 'Row ID' ENTMAP off
COLUMN primary_key FORMAT a75 HEADING 'Primary Key' ENTMAP off
COLUMN filter_columns FORMAT a75 HEADING 'Filter Columns' ENTMAP off
BREAK ON report ON log_owner
SELECT
'
, log_table
, master
, '
, '
, '
FROM
sys.dba_snapshot_logs
ORDER BY
log_owner;
CLEAR COLUMNS BREAKS COMPUTES
COLUMN ref_temp_name HEADING 'Refresh Template Name' ENTMAP off
COLUMN owner HEADING 'Owner' ENTMAP off
COLUMN public_template HEADING 'Public' ENTMAP off
COLUMN instantiated HEADING '# of Instantiated Sites' ENTMAP off
COLUMN template_comment HEADING 'Comment' ENTMAP off
SELECT
rt.refresh_template_name ref_temp_name
, owner owner
, decode(public_template, 'Y', 'YES', 'NO') public_template
, rs.instantiated instantiated
, rt.template_comment template_comment
FROM
sys.dba_repcat_refresh_templates rt
, (SELECT y.refresh_template_name, count(x.status) instantiated
FROM sys.dba_repcat_template_sites x, sys.dba_repcat_refresh_templates y
WHERE x.refresh_template_name(+) = y.refresh_template_name
GROUP BY y.refresh_template_name) rs
WHERE
rt.refresh_template_name(+) = rs.refresh_template_name
ORDER BY
rt.refresh_template_name;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - MASTER SITE LOGS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Master Site Logs
CLEAR COLUMNS BREAKS COMPUTES
COLUMN log_owner FORMAT a75 HEADING 'Log Owner' ENTMAP off
COLUMN log_table HEADING 'Log Table' ENTMAP off
COLUMN master HEADING 'Master' ENTMAP off
COLUMN rowids FORMAT a75 HEADING 'Row ID' ENTMAP off
COLUMN primary_key FORMAT a75 HEADING 'Primary Key' ENTMAP off
COLUMN filter_columns FORMAT a75 HEADING 'Filter Columns' ENTMAP off
BREAK ON report ON log_owner
SELECT
'
, log_table
, master
, '
, '
, '
FROM
sys.dba_snapshot_logs
ORDER BY
log_owner;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - MASTER SITE TEMPLATES - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Master Site Templates
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner HEADING 'Owner' ENTMAP off
COLUMN refresh_template_name HEADING 'Refresh Template Name' ENTMAP off
COLUMN public_template HEADING 'Public' ENTMAP off
COLUMN instantiated HEADING '# of Instantiated Sites' ENTMAP off
COLUMN template_comment HEADING 'Comment' ENTMAP off
BREAK ON owner
SELECT
'
, rt.refresh_template_name refresh_template_name
, decode(public_template, 'Y', 'YES', 'NO') public_template
, rs.instantiated instantiated
, rt.template_comment template_comment
FROM
sys.dba_repcat_refresh_templates rt
, ( SELECT y.refresh_template_name, count(x.status) instantiated
FROM sys.dba_repcat_template_sites x, sys.dba_repcat_refresh_templates y
WHERE x.refresh_template_name(+) = y.refresh_template_name
GROUP BY y.refresh_template_name
) rs
WHERE
rt.refresh_template_name(+) = rs.refresh_template_name
ORDER BY
owner;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - SITE SUMMARY - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Site Summary
CLEAR COLUMNS BREAKS COMPUTES
COLUMN mvgroup HEADING '# of Materialized View Groups' ENTMAP off
COLUMN mv HEADING '# of Materialized Views' ENTMAP off
COLUMN rgroup HEADING '# of Refresh Groups' ENTMAP off
SELECT
a.mvgroup mvgroup
, b.mv mv
, c.rgroup rgroup
FROM
( select count(s.gname) mvgroup
from sys.dba_repsites s
where s.snapmaster = 'Y') a
, ( select count(*) mv
from sys.dba_snapshots) b
, ( select count(*) rgroup
from sys.dba_refresh) c;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - SITE GROUPS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Site Groups
CLEAR COLUMNS BREAKS COMPUTES
COLUMN gname HEADING 'Name' ENTMAP off
COLUMN dblink HEADING 'Master' ENTMAP off
COLUMN propagation HEADING 'Propagation' ENTMAP off
COLUMN remark HEADING 'Remark' ENTMAP off
SELECT
s.gname gname
, s.dblink dblink
, decode(s.prop_updates, 0, 'Async', 'Sync') propagation
, g.schema_comment remark
FROM
sys.dba_repsites s
, sys.dba_repgroup g
WHERE
s.gname = g.gname
AND s.snapmaster = 'Y'
ORDER BY
s.gname;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - SITE MATERIALIZED VIEWS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Site Materialized Views
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN name HEADING 'Name' ENTMAP off
COLUMN master_owner HEADING 'Master Owner' ENTMAP off
COLUMN master_table HEADING 'Master Table' ENTMAP off
COLUMN master_link HEADING 'Master Link' ENTMAP off
COLUMN type HEADING 'Type' ENTMAP off
COLUMN updatable FORMAT a75 HEADING 'Updatable?' ENTMAP off
COLUMN can_use_log FORMAT a75 HEADING 'Can Use Log?' ENTMAP off
COLUMN last_refresh FORMAT a75 HEADING 'Last Refresh' ENTMAP off
BREAK ON owner
SELECT
'
, s.name name
, s.master_owner master_owner
, s.master master_table
, s.master_link master_link
, nls_initcap(s.type) type
, '
, '
, '
') || '
FROM
sys.dba_snapshots s
, sys.dba_mviews m
WHERE
s.name = m.mview_name
AND s.owner = m.owner
ORDER BY
s.owner
, s.name;
prompt
-- +----------------------------------------------------------------------------+
-- | - (MATERIALIZED VIEW) - SITE REFRESH GROUPS - |
-- +----------------------------------------------------------------------------+
prompt
prompt (Materialized View) - Site Refresh Groups
CLEAR COLUMNS BREAKS COMPUTES
COLUMN owner FORMAT a75 HEADING 'Owner' ENTMAP off
COLUMN name FORMAT a75 HEADING 'Name' ENTMAP off
COLUMN broken FORMAT a75 HEADING 'Broken?' ENTMAP off
COLUMN next_date FORMAT a75 HEADING 'Next Date' ENTMAP off
COLUMN interval FORMAT a75 HEADING 'Interval' ENTMAP off
BREAK ON owner
SELECT
'
, '
, '
, '
') || '
, '
FROM
sys.dba_refresh
ORDER BY
rowner
, rname;
prompt
-- +----------------------------------------------------------------------------+
-- | - END OF REPORT - |
-- +----------------------------------------------------------------------------+
SPOOL OFF
SET MARKUP HTML OFF
SET TERMOUT ON
prompt
prompt Output written to: &FileName._&_dbname._&_spool_time..html
EXIT;
Hope it helps.
Best regards,
Rafi.