Thursday, October 1, 2009

V$OPEN_CURSOR


V$OPEN_CURSOR lists cursors that each user session currently has opened and parsed.
Column
Datatype
Description
SADDR
RAW(4 | 8)
Session address
SID
NUMBER
Session identifier
USER_NAME
VARCHAR2(30)
User that is logged in to the session
ADDRESS
RAW(4 | 8)
Used with HASH_VALUE to uniquely identify the SQL statement being executed in the session
HASH_VALUE
NUMBER
Used with ADDRESS to uniquely identify the SQL statement being executed in the session
SQL_ID
VARCHAR2(13)
SQL identifier of the SQL statement being executed in the session
SQL_TEXT
VARCHAR2(60)
First 60 characters of the SQL statement that is parsed into the open cursor
LAST_SQL_ACTIVE_TIME
DATE
Time when this cursor was last executed
SQL_EXEC_ID
NUMBER
If the open cursor is executing, then the SQL execution identifier for that execution (see V$SQL_MONITOR)
Note:
1.       V$OPEN_CURSOR related queries:
·          Count open cursors by username and SID

select user_name, SID, count(*) cursors
from V$OPEN_CURSOR
group by User_Name, SID
order by User_Name, SID;
·          displays information on cursor usage for the current session

select * from V$SESSION_CURSOR_CACHE;
·          displays information on cursor usage for the system.

select * from V$SYSTEM_CURSOR_CACHE;
·          list current users and the sql executing

select SID, User_Name, SQL_Text
from V$OPEN_CURSOR
order by SID, User_Name, SQL_Text;
·          list details of current open cursors

select user_name,to_char(sysdate,'hh24:mi:ss') col1, sql_text
from V$OPEN_CURSOR;
·          query the subtotal and total usage of open cursors
select user_name, count(*)
from v$open_cursor
group by rollup(user_name)
order by count(*);
·          find out the transaction id for a particular DML statement that a user is running; this query can be used to find out the DML statement that a user is currently running

select t.XIDUSN || '.' || t.XIDSLOT || '.' || t.XIDSQN TRANSACTION_ID, q.sql_text
from   v$transaction t, v$session s, v$open_cursor o, v$sqltext q
where  t.addr = s.taddr and s.saddr = o.saddr and
       s.sid = o.sid and o.address = q.address and
       o.hash_value = q.hash_value and s.username = 'USERNAME'
order by q.address, q.hash_value, q.piece;

2.       Useful joins with V$OPEN_CURSOR
·          SID: Join to V$SESSION.SID
·          SADDR: Join to V$SESSION.SADDR
·          (ADDRESS,HASH_VALUE): Join to V$SQL.(ADDRESS,HASH_VALUE)
·          (ADDRESS,HASH_VALUE): Join to V$SQLTEXT.(ADDRESS,HASH_VALUE)

3.       Parameter related: OPEN_CURSORS


4.       Oracle error related:
ORA-1000: maximum open cursors exceeded
------------------------------------------------------------------------
Cause:  A host language program attempted to open too many cursors.
        The initialization parameter OPEN_CURSORS determines the maximum
        number of cursors per user.
Action: Modify the program to use fewer cursors.
        If this error occurs often, shut down Oracle, increase the value of
        OPEN_CURSORS, and then restart Oracle.


Last updated: Thursday, October 1, 2009

Oracle data dictionary views



Tuesday, September 22, 2009

V$TABLESPACE


V$TABLESPACE displays tablespace information from the control file.
Column
Datatype
Description
TS#
NUMBER
Tablespace number
NAME
VARCHAR2(30)
Tablespace name
INCLUDED_IN_DATABASE_BACKUP
VARCHAR2(3)
Indicates whether the tablespace is included in full database backups using the BACKUP DATABASE RMAN command (YES) or not (NO); NO only if the CONFIGURE EXCLUDE RMAN command was used for this tablespace
BIGFILE
VARCHAR2(3)
Indicates whether the tablespace is a bigfile tablespace (YES) or a smallfile tablespace (NO)
FLASHBACK_ON
VARCHAR2(3)
Indicates whether the tablespace participates in FLASHBACK DATABASE operations (YES) or not (NO)
ENCRYPT_IN_BACKUP
VARCHAR2(3)
Indicates whether encryption is turned ON or off at the tablespace level:
  • ON - Encryption is turned ON at the tablespace level
  • OFF - Encryption is turned OFF at the tablespace level
  • NULL - Encryption is neither explicitly turned on nor off at the tablespace level (default or when cleared)

Last updated: Tuesday, September 22, 2009

Oracle data dictionary views


Tuesday, September 15, 2009

RMAN dynamic views


The following Oracle dynamic views can be used to obtain RMAN information stored in the control file:
·         V$ARCHIVED_LOG: show which archives have been created, backed up, and cleared in the database.
·         V$BACKUP_CORRUPTION: show which blocks have been found to be corrupt during a backup of a backup set.
·         V$BACKUP_DATAFILE: useful for creating equal-sized backup sets by determining the number of blocks in each datafile. It can also help you find the number of corrupt blocks in the datafile.
·         V$BACKUP_DEVICE: display information about supported backup devices. DISK is not returned because it is always available.
·         V$BACKUP_FILES: display information about all RMAN backups (image copies and backup sets) and archived logs. The view simulates the LIST BACKUP and LIST COPY commands.
·         V$BACKUP_PIECE: show backup pieces created for backup sets.
·         V$BACKUP_REDOLOG: show archived logs stored in backup sets.
·         V$BACKUP_SET: show backup sets that have been created.
·         V$BACKUP_SPFILE: display information about server parameter files in backup sets.
·         V$COPY_CORRUPTION: show which blocks have been found to be corrupt during an image copy.
·         V$DATABASE_BLOCK_CORRUPTION: list database blocks marked as corrupt during the most recent RMAN backup.
·         V$RMAN_CONFIGURATION: list information about RMAN persistent configuration settings.
·         V$PROXY_ARCHIVEDLOG, V$PROXY_DATAFILE: proxy settings for RMAN.
·         V$BACKUP_ASYNC_IO, V$BACKUP_SYNC_IO: backup performance statistics

Monday, September 14, 2009

V$BACKUP_DEVICE


V$BACKUP_DEVICE displays information about supported backup devices. If a device type does not support named devices, then one row with the device type and a null device name is returned for that device type. If a device type supports named devices then one row is returned for each available device of that type. The special device type DISK is not returned by this view because it is always available.
Column
Datatype
Description
DEVICE_TYPE
VARCHAR2(17)
Type of the backup device
DEVICE_NAME
VARCHAR2(513)
Name of the backup device
Note:
1.       Oracle errors related with V$BACKUP_DEVICE
Error:   ORA-27001
Text:    unsupported device type
---------------------------------------------------------------------------
Cause:   the specified device type is NOT supported on this platform
Action:  check V$BACKUP_DEVICE for supported device types
Error:   ORA-4350
Text:    unsupported device type
---------------------------------------------------------------------------
Cause:   the specified device type is unsupported on this platform
Action:  check V$BACKUP_DEVICE for supported device types
Error:   ORA-27020
Text:    named devices not supported
---------------------------------------------------------------------------
Cause:   the platform or the specified device type does not support named devices
Action:  do not specify device name or use a device type that supports named devices. Use
          V$BACKUP_DEVICE view to see what device types and names (if any) are available.
2.       select * from v$backup_device;
SQL>  SELECT * FROM V$BACKUP_DEVICE;
DEVICE_TYPE       DEVICE_NAM
----------------- ----------
SBT_TAPE

Oracle data dictionary views

Last updated: Monday, September 14, 2009

V$RECOVERY_AREA_USAGE


V$RECOVERY_AREA_USAGE displays usage information about recovery areas.
Column
Datatype
Description
FILE_TYPE
VARCHAR2(20)
File type:
  • CONTROL FILE
  • REDO LOG
  • ARCHIVED LOG
  • BACKUP PIECE
  • IMAGE COPY
  • FLASHBACK LOG
  • REMOTE ARCHIVED LOG
PERCENT_SPACE_USED
NUMBER
Percent of the recovery area that is in use
PERCENT_SPACE_RECLAIMABLE
NUMBER
Percent of the recovery area that is reclaimable
NUMBER_OF_FILES
NUMBER
Number of files in the recovery area
Note:
1.       Replace V$FLASH_RECOVERY_AREA_USAGE in 11g.
2.       Query the V$RECOVERY_AREA_USAGE view to find out the percentage of the total disk quota used by different types of files. Also, you can determine how much space for each type of file can be reclaimed by deleting files that are obsolete, redundant, or already backed up to tape. For example, enter the following query (sample output included):
SELECT * FROM   V$RECOVERY_AREA_USAGE;
FILE_TYPE    PERCENT_SPACE_USED PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
------------ ------------------ ------------------------- ---------------
CONTROLFILE                   0                         0               0
ONLINELOG                     2                         0              22
ARCHIVELOG                 4.05                      2.01              31
BACKUPPIECE                3.94                      3.86               8
IMAGECOPY                 15.64                     10.43              66
FLASHBACKLOG                .08                         0               1

Oracle data dictionary views

Last updated: Monday, September 14, 2009