Monday, January 9, 2012

Migration of Oracle 10g Database to ASM (Automatic Storage Management) on Virtual Machine


Migration of Oracle 10g Database to ASM (Automatic Storage Management) on Virtual Machine



Step 1: Open Virtual Machine (Vmware_workstation 7.0)
Step 2: Add Hard Drive (Here i am using 3 Hard Drives).
a. Click on the "Edit virtual machine settings".
b. Click on "Add..." Button.
c. Select "Hard Disk," press "Next" button.
d. Select "Create a new virtual disk", press "Next" button.
e. Select "SCSI" and "Independent Persistent", press "next" button.
f. Specify the required Hard Drive space in "Maximum disk size (GB)", press "Next" and "Finish".
NOTE: Repeat the "Step 2:" as many disk you want to add.
Step 3: Start Virtual Machine
Step 4: Now create the RAW Device
a. Partition the disk driver.
1. Login as root user
   # fdisk -l
  # cd /dev/
  # ls sd*
  sda sdb sdc sdd sde
 # fdisk /dev/sdb (sdc, sdd ......)
   command (m for help): n (Choose 'n' command)
  command action
  e extend
  p primary partition (1-4)
  p (Choose 'p' command)
  Partition Number (1-4): 1 (Choose '1')
  First Cylinder (1-1115, default 1): (Press Enter)
  Last cylinder or +size or +sizeM or +sizeK (1-1305,
default 1305): (Press Enter)
  . . . .
   . . . .
  Command (m for help): w (Choose 'w' command)
  The partition table has been altered!    Calling ioctl() to re-read partition table.   Syncing disks.
NOTE: Repeat the above same steps for remaining Disk.
b. Binding raw device with partition on new SCSI disk.
                                  a. Login as root.
      # raw /dev/raw/raw1 /dev/sdb1
      # raw /dev/raw/raw2 /dev/sdc1
      # raw /dev/raw/raw3 /dev/sdd1
c. Change the ownership and peof the raw device.
  a. Login as root
      # cd /dev/raw
      # chown oracle:dba raw[1-3]
      #chmod 600 /dev/raw/raw1
      #chmod 600 /dev/raw/raw2
      # chmod 600 /dev/raw/raw3
Step 4: ASM Creation using raw devices
a. To configure as ASM instance, start the Database Configuration Assistant by issuing the "dbca"     command as the oracle user.
b. On the "Welcome" screen, click the "Next" button.
c. Select the "Configure Automatic Storage Management" option, then click "Next" button.
d. If the Oracle Cluster Synchronization Service (CSS) is not running currently, a warning screen will be displayed. Follow the instruction and click "OK". Once the service started click "Next" button.
NOTE: Script gives the o/p.
 # /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add
   /etc/oracle does not exist. Creating it now.
   Successfully accumulated necessary OCR keys.
   Creating OCR keys for user 'root', privgrp 'root'..
   Operation successful.
   Configuration for local CSS has been initialized
   Adding to inittab
   Startup will be queued to init within 90 seconds.
   Checking the status of new Oracle init process...
   Expecting the CRS daemons to be up within 600 seconds.
   CSS is active on these nodes.
     centos2
   CSS is active on all nodes.
   Oracle CSS service is installed and running under init(1M)
e. Enter the password for the ASM instance, then click "Next" button.
f. On the conformation screen, click "Ok" button.
g. Wait while the asm instance is cleared.
h. Once the asm creation is done, you are presented with the "ASM Disk Group" screen. Click "Create New" button.
i. On the "Create Disk Group" screen, enter Disk Group Name of "DATA" and select the required level  of redundancy.
 - External:
ASM does not mirror the files. This option should only be used if your disk are already  protected by some form of redundancy, like RAID
 - Normal:
  ASM performs two-way mirroring of all files.
 - High:
  ASM performs three-way mirroring of all files.
j. If you don't see disks which you believes should be available, then press on "Change Disk Discovery path..."
NOTE: Add raw devices path like this: /dev/raw/raw1,/dev/raw/raw2,/dev/raw/raw3
And then press "Ok" button.
h. On the "ASM Disk Groups " screen, Click the "Finish" button.
i. Click "Yes" button to perform another operation. (Now you are ready to create a database instance using ASM)
Step 5: Migration of Oracle 10g Database to ASM
a. Login as oracle user
b. Set the environment
c. start the listener
 $lsnrctl start
d. Disable Block change tracking:
$ sqlplus "/as sysdba"
SQL>  select * from v$block_change_tracking;
STATUS  FILENAME  BYTES
-----------------------------------------------
DISABLED
NOTE: If not disable then, disable using below command:
SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
Database altered
e. Shutdown the database
SQL>shutdown immediate
SQL> exit
f. Create pfile and add/modify the following parameters:
SQL> create pfile from spfile;
File created.
Parameters:
------------------
*.control_files=+DATA
*.db_recovery_file_dest=+DATA
*.db_recovery_file_dest_size=2147483648
*.db_create_file_dest=+DATA
*.db_create_online_log_dest_1=+DATA
g. Create spfile back from modified pfile:
SQL> create spfile from pfile;
File created
SQL> exit
h. Copy Database to ASM diskgroups using RMAN
 - start the instance on nomount
                                 - Copy the control file from old location to ASM using
                                 - Mount the database
                                 - copy the datafiles to ASM disk group using rman
 - Switch database to copy and open the database
                                  $ rman
                                   RMAN> connect target
                                   Connected to target database (not started)
                                   RMAN> startup nomount
   RMAN> restore controlfile from '/u01/app/oracle/oradata/prod/contorl01.ctl';
   RMAN> startup mount
   RMAN> configure device type disk parallelism 4;
   RMAN> backup as copy database format '+DATA';
                                   RMAN> switch database to copy;
   RMAN> alter database open;
   RMAN> exit

i. Migration tempfile to ASM:
 - tempfile can't be migrate using RMAN, it has to be migrate manually to ASM.
 $ sqlplus "/as sysdba"
 SQL> select name, bytes from v$tempfile;
NAME                                                                                     BYTES
------------------------------------------------------------------------------
/u01/app/oracle/oradata/prod/temp01.dbf    20971520
SQL> create temporary tablespace temp1 tempfile SIZE 100M extent management local   uniform size 1M;
  Tablespace created.
 SQL> alter database default temporary tablespace temp1;
  Database altered.
 SQL> drop tablespace temp including contents;
  Tablespace dropped.
  SQL> create temporary tablespace temp tempfile SIZE 100M extent management local    uniform size 1M;
  Tablespace created.
 SQL> alter database default temporary tablespace temp;
  Database altered.
SQL> drop tablespace temp1 including contents;
  Tablespace dropped.
 SQL> select name from v$tempfile;
  NAME
  ------------------------------------------------------------------------------
  +DATA/prod/tempfile/temp.264.596370217
j. Migrate and drop the old Online Redo Logs to ASM
 - Run the following procedure to migrate the redo logs to ASM.
SQL> declare cursor orlc is  select lf.member, l.bytes from v$log l, v$logfile lf where
             l.group# = lf.group# and lf.type = 'ONLINE' order by l.thread#, l.sequence#;
             type numTab_t is table of number index by binary_integer; type charTab_t is table of varchar2(1024) index by binary_integer;
byteslist numTab_t; namelist charTab_t;  procedure migrateorlfile(name IN varchar2, bytes IN number) is
 retry number; stmt varchar2(1024);   als varchar2(1024) := 'alter system switch logfile'; 
begin  select count(*) into retry from v$logfile;    stmt := 'alter database add logfile size ' || bytes;
execute immediate stmt; stmt := 'alter database drop logfile ''' || name || ''''; for i in 1..retry loop
 begin execute immediate stmt;  exit; exception when others then if i > retry then raise; 
 end if;  execute immediate als;
  end; 
 end loop;
 end;
begin  open orlc; fetch orlc bulk collect into namelist, byteslist;
close orlc; for i in 1..namelist.count loop migrateorlfile(namelist(i), byteslist(i));
 end loop; 
end;
 /

 SQL> select member from v$logfile;  
      MEMBER
      --------------------------------------------------------------------------------  
      +DATA/prod/onlinelog/group_3.259.596373299 
      +DATA/prod/onlinelog/group_2.258.596373295
      /u01/app/oracle/oradata/prod/redo01.log
      +DATA/prod/onlinelog/group_4.257.596373293   
    SQL> alter system switch logfile;   
                                 System altered.  
                     SQL> /    
                              System altered.
     SQL> /   
                          System altered.
                      SQL> /
                                  System altered.
  - Re-Execute the same script again in order to migrate the remaining ones. 
SQL> declare  cursor orlc is   select lf.member, l.bytes  from v$log l, v$logfile lf
where l.group# = lf.group# and lf.type = 'ONLINE' order by l.thread#, l.sequence#;
 type numTab_t is table of number index by binary_integer; type charTab_t is table of varchar2(1024) index by binary_integer;
 byteslist numTab_t; namelist charTab_t; procedure migrateorlfile(name IN varchar2, bytes IN number) is retry number;
  stmt varchar2(1024); als varchar2(1024) := 'alter system switch logfile';
begin  select count(*) into retry from v$logfile; stmt := 'alter database add logfile size ' || bytes;
execute immediate stmt; stmt := 'alter database drop logfile ''' || name || ''''; for i in 1..retry loop
begin execute immediate stmt;   exit;
exception  when others then   if i > retry then raise;  end if; execute immediate als;
 end; 
end loop;
end;
begin open orlc;  fetch orlc bulk collect into namelist, byteslist; close orlc;
for i in 1..namelist.count loop migrateorlfile(namelist(i), byteslist(i));
end loop;
 end; 
/

 SQL> select member from v$logfile;
        MEMBER 
         -------------------------------------------------------------------------------- 
        +DATA/prod/onlinelog/group_3.259.596373619
        +DATA/prod/onlinelog/group_2.258.596373615 
        +DATA/prod/onlinelog/group_1.261.596373613 
        +DATA/prod/onlinelog/group_4.257.596373293 
        +DATA/prod/onlinelog/group_5.260.596373609
 SQL> exit
k. Delete The old Datafiles using RMAN.
 $ rman target /
RMAN> run {
  2> delete copy of database
  3> }
  RMAN> exit
l. Enable the block change tracking.
 SQL> alter database enable block change tracing;
 Database altered.
m. Now your database is ready to use using ASM.





Monday, March 28, 2011

Oracle Application Release 12 Single Node Installation Document

Disk space requirements:

Application node (Fresh & Vision database) - 28 GB

Database node for Fresh database - 45GB

Database node for Vision demo database - 133GB

Stage area size - 33GB

Total Space for fresh Install - 73GB

Total Space for Vision - 161GB

Operating System Name

Supported Version

Red Hat Enterprise Linux

4.0 - Update 4 or higher (32-bit)

Kernel Requirements:

The following table lists the required minimum kernel versions.

Operating System

Kernel

Instructions

Red Hat Enterprise Linux AS/ES 4.0

2.6.9-42.EL

To determine version, $ uname - r

Required Packages:

Check required rpms installed or not (Eg : rpm –q glibc-2.3.4-2.25 )

glibc-2.3.4-2.25

glibc-common-2.3.4-2.25

binutils-2.15.92.0.2-21

compat-libstdc++-296-2.96-132.7.2

gcc-3.4.6-3

gcc-c++-3.4.6-3

libgcc-3.4.6-3

libstdc++-3.4.6-3

libstdc++-devel-3.4.6-3

openmotif21-2.1.30-11.RHEL4.6

pdksh-5.2.14-30.3

setarch-1.6-1

make-3.80-6.EL4

gnome-libs-1.4.1.2.90-44.1

sysstat-5.0.5-11.rhel4

compat-db-4.1.25-9

control-center-2.8.0-12.rhel4.5

xscreensaver-4.18-5.rhel4.11

libaio-0.3.105-2

libaio-devel-0.3.105-2

After installing these patches, run ldconfig -v. The openmotif package version numbering must be 2.1.30. For example, openmotif-2.2.3-10.RHEL4.5 is not supported.

Java version Requirements

$java –version

Java version should be minimum 1.4.2.

Sites to Download Rpms:

http://rpm.pbone.net/

http://linuxsoft.cern.ch/

Software Requirements:

Check this Softwares installed. ( Eg : which ar )

Ar, gcc , g++ , ld , ksh, make, Xdisplay

Kernel Settings:

Set following kernel parameters in /etc/sysctl.conf

set kernel.semmsl=256

set kernel.semmns=32000

set kernel.semopm=100

set kernel.semmni=142

set kernel.shmall=2097152

set kernel.shmmax=2147483648 (half of memory)

set kernel.shmmni=4096

set kernel.msgmax=8192

set kernel.msgmnb=65535

set kernel.msgmni=2878

set fs.file-max=65536

set net.ipv4.ip_local_port_range=1024 65000

set net.core.rmem_default=262144

set net.core.rmem_max=262144

set net.core.wmem_default=262144

set net.core.wmem_max=262144

After editing the file, use the "sysctl -p" command or restart the system to invoke the new

settings.

Domain Name System (DNS) Resolver Parameters:

Following entries to these minimum settings in the /etc/resolv.conf file on each server node:

options attempts:5
options timeout:15

Verifying Host Names:

Verify that the /etc/hosts file is formatted as follows:

127.0.0.1 localhost.localdomain localhost

      . 

Verify that the /etc/sysconfig/network file is formatted as follows:

HOSTNAME=.

If the /etc/sysconfig/networking/profiles/default/network file exists, remove it.

If you changed any files in the previous steps, restart the system.

Modifying the Number of Open File Descriptors:

Open the /etc/security/limits.conf file and change the existing values for "hard" and "soft" parameters as follows. Restart the system after making changes.

  * hard nofile 65535
  * soft nofile 4096
  * hard nproc 16384
  * soft nproc 2047
 
 
Net Service Listeners in Multi-user Installations:
 
$ chmod 777 /var/tmp/.oracle
 
 

Creating the Stage Area Directory:

Create directory for staging

$cd /

$mkdir stage

Verify software version (perl).

You must have perl 5.0053 or higher installed, and it must be in your PATH. Use

the following commands to identify the perl version and its location. The command

is the same for both UNIX and Windows platforms:

$perl -v

 

Mount the DVD

 

Run the adautostg.pl script.

 

$ perl /mnt/cdrom/Disk1/rapidwiz/adautostg.pl

Before starting installation check rapidwiz version:

Current Version of Rapid Install

The most current version of the Rapid Install wizard is 12.0.0.22. You can obtain this version by applying patch 5885627, available at OracleMetaLink. To verify your current version, use the RapidWizVersion executable, located in the rapidwiz directory on the Start Here DVD. For example:

UNIX:

$ cd /Stage12/startCD/Disk1/rapidwiz
$ ./RapidWizVersion
 

To update the Start Here DVD, uncompress the patch in the main staging area to overwrite the startCD directory. For example:

UNIX:

$ cd /Stage12
$ unzip -o p5885627_R12_GENERIC.zip
 
 

OS user account settings:

Create group for user

$groupadd dba

$useradd –g dba oracle

$useradd –g applmgr

Change read write execute permission and ownership to directories where going to install application and database

$chmod 777 /u01

$chmod 777 /u02

Start installation

$ /stage/Stage12i/startCD/Disk1/rapidwiz/rapidwiz

Sample screen shots of Oracle Applications Release 12 Rapid Install Wizard

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Application Home Page:

http://hostname.domainname:8000

Make profile entry for Users

For Database tier User ( .bash_profile )

. /u01/oracle/PROD/db/tech_st/10.2.0/PROD_r12.env

For Application tier User ( .bash_profile )

. /u02/oracle/PROD/apps/apps_st/appl/APPSPROD_r12.env

References:

Metalink Note: 402310.1

Oracle Applications Installation and Upgrade Notes Release 12 for Linux (32-bit)

Metalink Note: 405565.1

Oracle Applications Release 12 Installation Guidelines

Metalink Note: 405293.1

Oracle Applications Release Notes Release 12

B31295-04

http://download.oracle.com/docs/cd/B40089_05/current/acrobat/120oaig.pdf

Oracle Views

Oracle's V$ Views
The following views are part of the data dictionary.
See also Oracle's x$ tables
v$archive_dest
Shows all archived redo log destinations. Use this view to find out to which place archived redo logs are copied: select dest_id,destination from v$archive_dest
These values correspond to the init parameter log_archive_dest_n.
v$archive_dest_status
This view allows to find status and errors for each of the defined
v$archived_log
Displays successfully archived redo logs.
shows received logs on a primary standby database.
v$archive_gap
Lists sequence numbers of the archived los that are known to be missing for each thread on a (physical?) standby database (highest gap only).
v$archive_processes
This view provides information on the archive processes. It can be used to find out if an ARCH process is active or not.
v$controlfile
Displays the location and status of each controlfile in the database.
v$controlfile_record_section
See sections in a controlfile.
v$bh
This dynamic view has an entry for each block in the database buffer cache.
v$buffer_pool
See buffer pools.
This view's column id can be joined with x$kcbwds.indx
See also x$kcbwbpd
v$buffer_pool_statistics
v$database
This view lets you access database information. For example, you can check (using log_mode) whether or not the database is in archivelog mode:
ADPDB>select log_mode from v$database;
LOG_MODE
------------
ARCHIVELOG
v$datafile
This view contains an entry for each datafile of the database.
This view can be used to find out which datafiles must be backed up in a cold backup:
select name from v$datafile
v$datafile_header
Various information about datafile headers. For example, if you're interested in when the a file's last checkpoint was:
select name, checkpoint_change#, to_char(checkpoint_time, 'DD.MM.YYYY HH24:MI:SS') from v$datafile_header
v$dataguard_status
Shows error messages in a data guard environment.
v$db_object_cache
This view displays objects that are cached (pinned) in the library cache. See also dbms_shared_pool.
v$enqueue_stat
If there are a lot of enqueue waits "in" v$session_event or v$system_event, v$enqueue_stat allows to break down those enqueues in enqueue classes. For each such class, the gets, waits, failures and the cumulative sum of waited time can be found.
For a list of enqueue types, refer to enqueue types in x$ksqst.
The column cum_wait_time stems from x$ksqst.ksqstwtim.
v$eventmetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$event_name
Contains a record for each wait event.
v$filemetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$filestat
v$fixed_table
This view contains the name of all V$, X$ and GV$ tables. In oracle 8.1.7, there are 187 different v$ tables:
ORA81> select count(*) from v where name like 'V$%';
COUNT(*)
----------
185
If you want to know, which x$ tables there are, do a select name from v$fixed_table where name like 'X$%';
v$fixed_view_definition
Contains the defintion in its attribute view_definition for the views of v$fixed_table.
v$flash_recovery_area_usage
See also v$recovery_file_dest
v$instance
instance_role can be used to determine if an instance is an active instance (=primary instance) or a secondary instance (in a standby environment.
dbms_utility.db_version can be used to retrieve the same version as the field version in v$instance.
v$instance_recovery
Can, for example, be used to determine the optimal size of redo logs.
v$latch
Oracle collects statistics for the activity of all latches and stores these in this view. Gets is the number of successful willing to wait requests for a latch. Similarly, misses is how many times a process didn't successfully request a latch. Spin_gets: number of times a latch is obtained after spinning at least once. Sleeps indicates how many times a willing to wait process slept. Waiters_woken tells how often a sleeping process was 'disturbed'.
v$librarycache
v$lock
This view stores all information relating to locks in the database. The interesting columns in this view are sid (identifying the session holding or aquiring the lock), type, and the lmode/request pair.
Important possible values of type are TM (DML or Table Lock), TX (Transaction), MR (Media Recovery), ST (Disk Space Transaction).
Exactly one of the lmode, request pair is either 0 or 1 while the other indicates the lock mode. If lmode is not 0 or 1, then the session has aquired the lock, while it waits to aquire the lock if request is other than 0 or 1. The possible values for lmode and request are:
* 1: null,
* 2: Row Share (SS),
* 3: Row Exclusive (SX),
* 4: Share (S),
* 5: Share Row Exclusive (SSX) and
* 6: Exclusive(X)
If the lock type is TM, the column id1 is the object's id and the name of the object can then be queried like so: select name from sys.obj$ where obj# = id1
A lock type of JI indicates that a materialized view is being refreshed.
A more detailed example can be found here
See also x$kgllk.
v$locked_object
Who is locking what:
select
oracle_username
os_user_name,
locked_mode,
object_name,
object_type
from
v$locked_object a,dba_objects b
where
a.object_id = b.object_id
v$log
Contains information on each log group. See also online redo log.
Comman values for the status column are:
* UNUSED:
Oracle8 has never written to this group,
* CURRENT:
This is the active group.
* ACTIVE:
Oracle has written to this log before, it is needed for instance recovery.
The active log is the one with the current log sequence number
* INACTIVE:
Oracle has written to this log before; it is not needed for instance recovery.
v$logfile
This view can be queried to find the filenames, group numbers and states of redo log files. For example, to find all files of group 2, use select member from v$logfile where group# = 2
v$logmnr_contents
See dbms_logmnr.
v$log_history
This view contains an entry for each Log Switch that occured. The column first_time indicates the time of the first entry???
On physical standby databases, this view shows applied logs.
v$logstdby
Can be used to verify that archived redo logs are being applied to standby databases.
v$managed_standby
Monitors the progress of a standby database in managed recovery mode, more exactly, it displays information about the activities of log transport service and log apply service.
see here
select process, pid, status, client_process, group# "Stdby Redo Log Gr", block# from v$managed_standby;
client_process: the corresponding primary database process. If lgwr log transmission is chosen, one row should have client_process=LGWR. If ARCH transmission is chosen, one row should have ARCH.
v$mystat
This view records statistical data about the session that accesses it. Join statistic# with v$statname.
v$sesstat is also similar to v$sysstat, except that v$sysstat accumulates the statistics as soon as a session terminates.
See also recording statistics with oracle.
v$nls_parameters
The NLS parameters that are in effect for the session quering this view. The view NLS_SESSION_PARAMETERS is based on v$nls_parameters. See also v$nls_valid_values.
v$nls_valid_values
This view can be used to obtain valid values for NLS parameters such as
* supported character sets
* languages
* territories
* sorting orders
v$object_usage
v$object_usage gathers information about used (accessed) indexes when an index is monitored using alter index ... monitoring usage.
See On verifying if an index is used.
v$open_cursor
v$option
This view lets you see which options are installed in the server.
See also dba_registry.
v$parameter
Lists the name-value pairs of the init.ora file (or their default, if not in the init.ora). For example, if you need to know what your block size is:
select value from v$parameter where name = 'db_block_size'
The columns isses_modifiable and issys_modifiable can be used to determine if a parameter can be changed at session level using alter session or at system level using alter system. A parameter is modifiable at session level if isses_modifiable = 'TRUE'. A parameter is modifiable at system level if issys_modifiable = 'DEFERRED' or issys_modifiable = 'IMMEDIATE'. However, if a parameter is changed at system level if issys_modifiable = 'DEFERRED' it only affects sessions that are started after chaning the parameter. Additionally, the alter system set ... deferred option must be used.
There are also some undocumented (or hidden?) parameters.
v$pgastat
See also pga.
Thanks to Oleg who notified me of a typo (v$pgastat instead of v$pga_stat).
v$process
Join v$process's addr with v$session paddr.
The column traceid is equal to the value used in alter session set .
v$pwfile_users
Lists all users who have been granted sysdba or sysoper privileges. See adding user to a password file.
v$recover_file
Useful to find out which datafiles need recovery.
Join with v$datafile to see filenames instead of numbers....
v$recovery_file_dest
See also v$flash_recovery_area_usage
v$reserved_words
This view can be consulted if one is in doubt wheter a particular word is a reserved word (for example when writing PL/SQL Code or assigning a password to a user).
Until 10g, the view only consist of two columns: keyword and length. From 10gR2 onwards, it has also the columns reserved, res_type, res_attr, res_semi and duplicate. Each of these new columns can only be either 'Y' (meaning: yes) or 'N' (meaning: no)
See also reserved words in SQL and reserved words in PL/SQL.
v$resource_limit
v$rollname
The names of online rollback segments. This view's usn field can be joined with v$rollstat's usn field and with v$transaction's xidusn field.
v$transaction can be used to track undo by session.
v$rollstat
Statistics for rollback segements
v$session
The column audsid can be joined with sys_context('userenv','SESSIONID') to find out which session is the "own one". Alternatively, dbms_support.mysid can be used.
The fields module and action of v$session can be set with dbms_application_info.set_module. (See v$session_longops for an example.
The field client_info can be set with dbms_application_info.set_client_info
Join sid with v$sesstat if you want to get some statistical information for a particular sesssion.
A record in v$session contains sid and serial#. These numbers can be used kill a session (alter system kill session).
A client can set some information in client_info. For example, RMAN related sessions can be found with
.... where client_info like 'rman%';
What a session is waiting for can be queried with v$session_wait. However, with Oracle 10g, this is not nessessary anymore, as v$session_wait's information will be exposed within v$session as well.
See also sessions.
v$sessmetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$session_event
This views is similar to v$system_event. However, it breaks it down to currently connected sessions.
v$session_event has also the column max_wait that shows the maximum time waited for a wait event.
v$session_longops
Use v$session_longops if you have a long running pl/sql procedure and want to give feedback on how far the procedure proceeded.
If the following Procedure is run, it will report its progress in v$session_longops. The Procedure will also set the module attribute in v$session which makes it possible to find the sid and serial# of the session.
create table f(g number);
create or replace procedure long_proc as
rindex pls_integer := dbms_application_info.set_session_longops_nohint;
slno pls_integer;
-- Name of task
op_name varchar2(64) := 'long_proc';
target pls_integer := 0; -- ie. The object being worked on
context pls_integer; -- Any info
sofar number; -- how far proceeded
totalwork number := 1000000; -- finished when sofar=totalwork
-- desc of target
target_desc varchar2(32) := 'A long running procedure';
units varchar2(32) := 'inserts'; -- unit of sofar and totalwork
begin
dbms_application_info.set_module('long_proc',null);
dbms_application_info.set_session_longops (
rindex,
slno);
for sofar in 0..totalwork loop
insert into f values (sofar);
if mod(sofar,1000) = 0 then
dbms_application_info.set_session_longops (
rindex,
slno,
op_name,
target,
context,
sofar,
totalwork,
target_desc,
units);
end if;
end loop;
end long_proc;
If the procedure long_proc is run, you can issue the following query to get feedback on its progress:
select time_remaining,sofar,elapsed_seconds
from v$session_longops l, v$session s
where l.sid=s.sid and l.serial# = s.serial# and s.module='long_proc'
v$session_wait
This views shows what wait event each session is waiting for, or what the last event was that it waited for.
In contrast, v$session_event lists the cumulative history of events waited for in a session.
The columns P1, P2 and P3 are parameters that are dependant on the event. With Oracle 10g, v$session_wait's information will be exposed within v$session as well.
Since 10g, Oracle displays the v$session_wait information also in the v$session view.
v$session_wait_history
This view is new in Oracle 10g and allows improved timing and statistics.
v$sesstat
This view is similar to v$mystat except that it shows cumulated statistics for all sessions.
Join sid with v$session and join statistic# with v$statname.
v$sesstat is also similar to v$sysstat, except that v$sysstat accumulates the statistics as soon as a session terminates.
v$sga
Shows how much memory the shared global area uses. Selecting * from v$sga is roughly the same as typing show sga in sql plus with the exeption that the latter also show the total.
v$sgastat
Showing free space in the sga:
select * from v$sgastat where name = 'free memory'
v$sga_dynamic_components
Information about SGA resize operations since startup.
This view can also be used to find out the granule size of SGA components.
v$sga_resize_ops
v$sort_usage
See temporary tablespaces
v$sort_segment
See Temporary Tablespaces
v$spparameter
Returns the values for the spfile.
v$sql
v$sql is similar to v$sqlarea, the main difference being that v$sql drills down to select * from x$kglob whereas v$sqlarea drills down to select sum from x$kglob. See also here.
v$sqlarea
Join v$sqlarea's address with v$session's sql_address.
Find the SQL-text of currently running SQL statements:
select sql_text from v$sqlarea where users_executing > 0;
The field version_count indicates how many versions an sql statement has.
v$sqltext
v$sql_plan
variable addr varchar2(20)
variable hash number
variable child number
exec :addr := '&sqladdr'; :hash := &hashvalue; :child := &childno;
select lpad(' ', 2*(level-1))||operation||' '||
decode(id, 0, 'Cost = '||position) "OPERATION",
options, object_name
from v$sql_plan
start with (address = :addr
and hash_value = :hash
and child_number = :child
and id=0 )
connect by prior id = parent_id
and prior address = address
and prior hash_value = hash_value
and prior child_number = child_number
order by id, position ;
In order to find valid values for sqladdr, hashvalue and childno, this SQL statement can be used:
select sql_text,address,hash_value,child_number from v$sql where users_executing > 0;
v$sqltext_with_newlines
This view can be used to construct the entire text for each session's actual SQL statement. Use the following statement to to that:
set serveroutput on size 1000000
declare
v_stmt varchar2(16000);
v_sql_text v$sqltext_with_newlines.sql_text%type;
v_sid v$session.sid%type;
begin
for r in (
select
sql_text,s.sid
from
v$sqltext_with_newlines t,
v$session s
where
s.sql_address=t.address
order by s.sid, piece) loop
v_sid := nvl(v_sid,r.sid);
if v_sid <> r.sid then
dbms_output.put_line(v_sid);
put_line(v_stmt,100);
v_sid := r.sid;
v_stmt := r.sql_text;
else
v_stmt := v_stmt || r.sql_text;
end if;
end loop;
dbms_output.put_line(v_sid);
dbms_output.put_line(v_stmt,100);
end;
/
Thanks to Sarmad Zafar who notified me of an error in this PL/SQL Block.
Note: the function put_line is found here and can be used to prevent ORU-10028.
v$sql_bind_data
Join cursor_num with cno of v$sql_cursor.
v$sql_bind_capture
New with Oracle 10g
This view captures bind variables for all sessions and is faster than setting 10046 on level 4.
v$sql_cursor
Join parent_handle with address of v$sql or v$sqlarea.
v$sql_workarea
v$sql_workarea can be joined with v$sqlarea on address and hash_value, and it can be joined with v$sql on address, hash_value and child_number.
v$standby_log
v$statname
Use this view to get decoded names for the statistic# field of v$mystat, v$sysstat and v$sesstat.
v$sysaux_occupants
v$sysaux_occupants doesn't exist in Oracle versions prior to Oracle 10g.
See occupants in the sysaux tablepsaces.
v$sysmetric
This view is new in Oracle 10g and allows improved timing and statistics.
v$sysmetric_history
This view is new in Oracle 10g and allows improved timing and statistics.
v$sysstat
v$sysstat is similar to v$sesstat. While v$sesstat displays statitics for the current session, v$sysstat displays the cumulated statitics since startup of the database.
For example, it is possible to find out the CPU time (name = 'CPU used by this session')
This view is (among others) used to calculate the Hit Ratio.
v$system_event
This view displays the count (total_waits) of all wait events since startup of the instance.
If timed_statistics is set to true, the sum of the wait times for all events are also displayed in the column time_waited.
The unit of time_waited is one hundreth of a second. Since 10g, an additional column (time_waited_micro) measures wait times in millionth of a second.
total_waits where event='buffer busy waits' is equal the sum of count in v$waitstat.
v$enqueue_stat can be used to break down waits on the enqueue wait event.
While this view totals all events in an instance, v$session_event breaks it down to all currently connected sessions.
v$undostat
undo tablespaces
v$tempfile
v$tempseg_usage
v$tempseg_usage is a public synonym for v$sort_usage.
v$tempstat
v$thread
The Oracle SID can be retrieved through select instance from v$thread
v$timer
This view has only one column (hsecs) which counts hundreths of seconds. Whenever it overflows four bytes, it starts again with 0.
v$transaction
Important fields of v$transaction are used_ublk and used_urec. They tell of how many blocks and records the undo for a transaction consists. In order to find out the name of the corresponding rollback segemnt, join the xidusn field with the usn field of v$rollname. This is demonstrated in
Transactions generate undo
v$timezone_names
See also timezones for some values of tzabbrev.
v$transportable_platform
Which platforms are supported for cross platform transportable tablespaces.
v$version
Use this view to find out what version you actually work on: select * from v$version;
BANNER
----------------------------------------------------------------
Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
PL/SQL Release 8.1.7.0.0 - Production
CORE 8.1.7.0.0 Production
TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
NLSRTL Version 3.4.1.0.0 - Production
v$waitstat
total_waits where event='buffer busy waits' is equal the sum of count in v$system_event.Oracle Important Views

Execution Plan & Statistics