Forgot your password?    
+ Reply to Thread
Results 1 to 1 of 1

Thread: Oracle Database V$ Views

  1. #1
    Join Date
    Oct 2011

    Oracle Database V$ Views

    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 parameterlog_archive_dest_n.

    This view allows to find status and errors for each of the defined
    Displays successfully archived redo logs.
    shows received logs on a primary standby database.

    Lists sequence numbers of the archived los that are known to be missing for each thread on a (physical?) standby database (highest gap only).

    This view provides information on the archive processes. It can be used to find out if an ARCH process is active or not.

    Displays the location and status of each controlfile in thedatabase.

    See sections in a controlfile.

    This dynamic view has an entry for each block in the database buffer cache.
    The column status can be:
    • free
    This block is not in use
    • xcur
    Block held exclusively by this instance
    • scur
    Block held in cache, shared with other instance
    • cr
    Block for consistent read
    • read
    Block being read from disk
    • mrec
    Block in media recovery mode
    • irec
    Block in instance (crash) recovery mode

    See buffer pools.
    This view's column id can be joined with x$kcbwds.indx
    See also x$kcbwbpd

    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;

    checkpoint_change# records the SCN of the last checkpoint.
    switchover_status: can be used to determine if it is possible to perform a switchover operation Only available for physical standby databases. Can be:
    • TO STANDBY or
    See protection modes in data guard for the columnsprotection_mode and protection_level.
    database_role determines if a database is a primary or alogical standby database or a physical standby database.
    force_logging tells if a database is in force logging mode or not.

    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

    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

    Shows error messages in a data guard environment.

    This view displays objects that are cached (pinned) in thelibrary cache. See also dbms_shared_pool.

    If there are a lot of enqueue waits "in" v$session_event orv$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.

    This view is new in Oracle 10g and allows improved timing and statistics.

    Contains a record for each wait event.

    This view is new in Oracle 10g and allows improved timing and statistics.


    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$%';

    If you want to know, which x$ tables there are, do a select name from v$fixed_table where name like 'X$%';

    Contains the defintion in its attribute view_definition for the views of v$fixed_table.
    See also v$recovery_file_dest

    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.

    Can, for example, be used to determine the optimal size of redo logs.

    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. Sleepsindicates how many times a willing to wait process slept.Waiters_woken tells how often a sleeping process was 'disturbed'.


    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 forlmode 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.

    Who is locking what:
    v$locked_object a,dba_objects b
    a.object_id = b.object_id

    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
    Oracle has written to this log before; it is not needed for instance recovery.

    This view can be queried to find the filenames, group numbersand states of redo log files. For example, to find all files of group 2, use select member from v$logfile where group# = 2

    See dbms_logmnr.

    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.

    Can be used to verify that archived redo logs are being applied to standby databases.

    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.

    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.

    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.
    This view can be used to obtain valid values for NLS parameters such as
    • supported character sets
    • languages
    • territories
    • sorting orders

    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.

    This view lets you see which options are installed in the server.
    See also dba_registry.

    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, thealter system set ... deferred option must be used.
    There are also some undocumented (or hidden?) parameters.

    See also pga.
    Thanks to Oleg who notified me of a typo (v$pgastat instead of v$pga_stat).

    Join v$process's addr with v$session paddr.
    The column traceid is equal to the value used in alter session set .

    Lists all users who have been granted sysdba or sysoperprivileges. See adding user to a password file.

    Useful to find out which datafiles need recovery.
    Join with v$datafile to see filenames instead of numbers....

    See also v$flash_recovery_area_usage

    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 andlength. From 10gR2 onwards, it has also the columnsreserved, 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.

    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.

    Statistics for rollback segements

    The column audsid can be joined withsys_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 withdbms_application_info.set_module. (See v$session_longopsfor an example.
    The field client_info can be set withdbms_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 withv$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.

    This view is new in Oracle 10g and allows improved timing and statistics.

    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.

    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 moduleattribute in v$session which makes it possible to find the sidand 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

    dbms_application_info.set_module('long_proc',null) ;

    dbms_application_info.set_session_longops (

    for sofar in 0..totalwork loop

    insert into f values (sofar);

    if mod(sofar,1000) = 0 then
    dbms_application_info.set_session_longops (

    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'

    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.

    This view is new in Oracle 10g and allows improved timing and statistics.

    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.

    Shows how much memory the shared global area uses. Selecting * from v$sga is roughly the same as typing show sgain sql plus with the exeption that the latter also show the total.

    Showing free space in the sga:
    select * from v$sgastat where name = 'free memory'
    Information about SGA resize operations since startup.
    This view can also be used to find out the granule size of SGA components.


    See temporary tablespaces

    See Temporary Tablespaces

    Returns the values for the spfile.

    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.

    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.

    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;
    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

    v_stmt varchar2(16000);
    v_sql_text v$sqltext_with_newlines.sql_text%type;
    v_sid v$session.sid%type;
    for r in (
    v$sqltext_with_newlines t,
    v$session s
    order by s.sid, piece) loop

    v_sid := nvl(v_sid,r.sid);

    if v_sid <> r.sid then
    <a href='oru_10028.html'>put_line</a>(v_stmt,100);
    v_sid := r.sid;
    v_stmt := r.sql_text;
    v_stmt := v_stmt || r.sql_text;
    end if;

    end loop;

    Join cursor_num with cno of v$sql_cursor.

    New with Oracle 10g
    This view captures bind variables for all sessions and is faster than setting 10046 on level 4.

    Join parent_handle with address of v$sql or v$sqlarea.

    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.


    Use this view to get decoded names for the statistic# field ofv$mystat, v$sysstat and



    v$sysaux_occupants doesn't exist in Oracle versions prior toOracle 10g.
    See occupants in the sysaux tablepsaces.

    This view is new in Oracle 10g and allows improved timing and statistics.

    This view is new in Oracle 10g and allows improved timing and statistics.

    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.

    This view displays the count (total_waits) of all wait eventssince 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 theenqueue wait event.
    While this view totals all events in an instance,v$session_event breaks it down to all currently connectedsessions.
    undo tablespaces
    v$tempseg_usage is a public synonym for v$sort_usage.
    The Oracle SID can be retrieved through select instance from v$thread
    This view has only one column (hsecs) which counts hundreths of seconds. Whenever it overflows four bytes, it starts again with 0.

    Important fields of v$transaction are used_ublk andused_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 theusn field of v$rollname. This is demonstrated in
    Transactions generate undo

    See also timezones for some values of tzabbrev.
    Which platforms are supported for cross platform transportable tablespaces.

    Use this view to find out what version you actually work on:select * from v$version;
    Oracle8i Enterprise Edition Release - Production
    PL/SQL Release - Production
    CORE Production
    TNS for 32-bit Windows: Version - Production
    NLSRTL Version - Production

    total_waits where event='buffer busy waits' is equal the sum of count in v$system_event.
    Last edited by Hemant; 01-03-2012 at 01:51 AM.

+ Reply to Thread

Similar Threads

  1. Materialized Views,Complete and Fast Refresh in 11g Oracle Database
    By ajaychandi in forum Database Performance Management,Database Links,Materialized Views
    Replies: 0
    Last Post: 01-12-2012, 11:03 PM
  2. Oracle Database V$ Views
    By Pradeep in forum Oracle Database Administration 10g and 11g
    Replies: 0
    Last Post: 12-14-2011, 05:04 AM
  3. Oracle ASM Views and Usage - Quick Reference/Understanding
    By Hemant in forum RAC Installation, ASM Install , ASM Administration
    Replies: 0
    Last Post: 11-21-2011, 04:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

DBA Lounge (P) Ltd. deals in Oracle Technologies on Consulting, Resourcing, Corporate Training

Online and corporate training available on Oracle Database 11g, Oracle 11g Real Application Cluster (RAC), Oracle Applications 11i/R12, Oracle Fusion Middleware 11g, Oracle Identity Management-OIM, Oracle Internet Directory 11g-OID, Oracle Business Intelligence Enterprise Edition-OBIEE, Oracle Golden Gate, Oracle Access Management-OAM, Oracle Internet Directory-ODS, Oracle Identity Analytics Architecture-OIA Statistics