V$sort_usage

anyone know how to select the user column from this view without
executing the user function and getting back who your logged in
as?? Thank you.

LOL. Looks like the problem is with the view itself. Try this
instead:
select username, v$sort_usage.*
from v$sort_usage, v$session
where v$session.sql_address = v$sort_usage.sqladdr

Similar Messages

  • V_$SORT_USAGE equivalent structure or table in abap

    Hi Experts,
    I want to access the contents of this oracle data dictionary view V_$SORT_USAGE for a particular tablespace through an abap program, so is there any structure used by a fm or some database tables or view which is equivalent to this view V_$SORT_USAGE.
    Through db02 I was able to get the structure similar to DBA_TABLESPACES of oracle database, in similar way i want information for this view in bw database
    Does anybody know about this information,
    It will be of great use to me.
    Thanks,
    Hema.

    Hi,
    While searching for the view V_$SORT_USAGE,I got the following information.Is it possible to call the view from a ABAP report using Native SQL?[EXEC SQL...ENDEXEC]
    For every user using temporary space, there is an entry in SYS.V$_LOCK with type 'TS'.
    All temporary segments are named 'ffff.bbbb' where 'ffff' is the file it is in and 'bbbb' is first block of the segment.
    If your temporary tablespace is set to TEMPORARY, all sorts are done in one large temporary segment. For usage stats, see SYS.V_$SORT_SEGMENT
    From Oracle 8.0, one can just query SYS.v$sort_usage. Look at these examples:
         select s.username, u."USER", u.tablespace, u.contents, u.extents, u.blocks
            from   sys.v_$session s, sys.v_$sort_usage u
            where  s.saddr = u.session_addr
            select s.osuser, s.process, s.username, s.serial#,
                   sum(u.blocks)*vp.value/1024 sort_size
            from   sys.v_$session s, sys.v_$sort_usage u, sys.v_$parameter vp
            where  s.saddr = u.session_addr
              and  vp.name = 'db_block_size'
              and  s.osuser like '&1'
            group  by s.osuser, s.process, s.username, s.serial#, vp.value

  • Sql_id in gv$sort_usage vs gv$session

    I've caught a strange(?) situation here.
    select sql_id from gv$sort_usage where session_addr='000000046A1932F0'; -- gives me 5bqt08ckavskx
    where as
    select sql_id from gv$session where saddr='000000046A1932F0'; -- gives me 1rztpy7a92vpn
    Because of this, I am not able to find the correct query which is consuming lots of temp segments. Well, actually, I am catching up those queries when things are apparent but I am now caught in a situation where two queries are somewhat similar and getting me confused. Why gv$sort_usage and gv$session are giving me different queries and which query is the one that is actually taking the huge temp segments?
    Any help is appreciated.
    Thanks
    gtcol

    You might find useful information in DBA_TEMP_FILES :
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:374218170986#76977305391283 (warning: long thread ;) ,but many alternatives)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/tspaces.htm#sthref1323
    Also dbms_xplan can be used to show you the estimated temp space needed by a query, using column temp_space from the plan_table:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#g30946

  • V$SORT_USAGEとV$SQLとV$SESSIONの連結SQLで.重複したデータを出力させないようにする方法

    下記SQL文でV$SORT_USAGEとV$SQLとV$SESSIONをJOINした結果を表示させようと思いますが、
    SESSION_ADDRが重複して出力されてしまいます。
    重複を排除したSQL文を出力させる方法をわかる方いましたら、教えてください。
    ※本来は、SELECTするカラムはもっと多いですが、ここでは省力しています。
    SELECT
         SORT.SESSION_ADDR
    FROM
         V$SESSION SES,
         V$SORT_USAGE SORT,
         V$SQL SQL
    WHERE
         SES.SADDR=SORT.SESSION_ADDR AND
         SES.SQL_ID=SQL.SQL_ID AND
         SES.SQL_CHILD_NUMBER = SQL.CHILD_NUMBER AND
         SES.SQL_ADDRESS=SQL.ADDRESS AND
         SORT.SQLADDR=SQL.ADDRESS AND
         SORT.SQLHASH=SQL.HASH_VALUE
    ORDER BY
         BLOCKS;
    SESSION_ADDR
    00000003FF79A788
    00000003FF79A788
    00000003FF79BCF0
    00000003FC7C9258
    00000003FF79BCF0
    00000003FC7C9258
    6 rows selected.
    【備考】
    ・表示するカラムにV$SORT_USAGE.SQL_FULLTEXT(CLOB)も含めたい為、distinct句で
    重複を排除する事ができません。
    ・DBはOracle10gです。

    すみません。上記は自己解決しました。
    ※SEGMENT_TYPE別にSQL文が出力されるのですね

  • What is the unit of EXTENT_SIZE in v$sort_usage , is it no. of blocks or bytes ?

    Hi All
    What is the unit of EXTENT_SIZE in v$sort_usage , is it no. of blocks or bytes ? for 11.2.0.4
    Thanks

    their is no such column in v$sort_usage
    However their is one extent column and it means "Extents allocated to the sort"
    VIEW v$sort_usage
    Name                                      Null?    Type                       
    USERNAME                                           VARCHAR2(30)               
    USER                                               VARCHAR2(30)               
    SESSION_ADDR                                       RAW(8)                     
    SESSION_NUM                                        NUMBER                     
    SQLADDR                                            RAW(8)                     
    SQLHASH                                            NUMBER                     
    SQL_ID                                             VARCHAR2(13)               
    TABLESPACE                                         VARCHAR2(31)               
    CONTENTS                                           VARCHAR2(9)                
    SEGTYPE                                            VARCHAR2(9)                
    SEGFILE#                                           NUMBER                     
    SEGBLK#                                            NUMBER                     
    EXTENTS                                            NUMBER                     
    BLOCKS                                             NUMBER                     
    SEGRFNO# 

  • ORA-00600: internal error code, arguments: [17183], [0x033134908], [], [],

    Hi Exports,
    I am getting the ORA-00600: internal error code, arguments: [17183], [0x033134908], [], [], [], [], [], []
    The temporary tablespace of the database is full and i am trying to do the following steps.
    SQL> select * from dba_temp_files;
    FILE_NAME FILE_ID TABLESPACE_NAME BYTES Blocks Etat RELATIVE_FNO AUT MAXBYTES MAXBLOCKS INCREMENT_BY
    USER_BYTES USER_BLOCKS
    G:\ORADATA\TEMP01.DBF 1 TEMP 3.4359E+10 4,194,176 AVAILA 1 YES 3.4360E+10 4194302 80
    3.4358E+10 4194048
    J:\ORADATA\TIVOLIORTEMPTS.DBF 5 TIVOLIORTEMPTS 104857600 12,800 AVAILA 1 NO 0 0 0
    103809024 12672
    J:\ORADATA\TEMP_ORISSA_MASTER.TMP 2 TEMP_ORISSA_MASTER 10485760 1,280 AVAILA 1 YES 52428800 6400 128
    9437184 1152
    J:\ORADATA\TEMP_ORISSA_BENCHMARK.TMP 3 TEMP_ORISSA_BENCHMARK 680525824 83,072 AVAILA 1 YES 1073741824 131072 2
    679477248 82944
    J:\ORADATA\TEMP_ORISSA_TRANSACTION 4 TEMP_ORISSA_TRANSACTION 104857600 12,800 AVAILA 1 YES 1073741824 131072 2
    103809024 12672
    5 rows selected.
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP 3.4359E+10 0
    TEMP_ORISSA_MASTER 4194304 6291456
    TEMP_ORISSA_BENCHMARK 680525824 0
    TEMP_ORISSA_TRANSACTION 37748736 67108864
    TIVOLIORTEMPTS 1048576 103809024
    5 rows selected.
    SQL> CREATE TEMPORARY TABLESPACE MYTEMPFILE
    2 TEMPFILE 'G:\ORADATA\TEMP001.dbf'
    3 SIZE 1000M AUTOEXTEND ON NEXT 10M MAXSIZE 2000M;
    Tablespace created.
    SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE MYTEMPFILE;
    Database altered.
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP 3.4359E+10 0
    TEMP_ORISSA_MASTER 4194304 6291456
    TEMP_ORISSA_BENCHMARK 680525824 0
    TEMP_ORISSA_TRANSACTION 37748736 67108864
    TIVOLIORTEMPTS 1048576 103809024
    MYTEMPFILE 1048576 1047527424
    6 rows selected.
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES;
    ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES
    ERROR at line 1:
    ORA-25152: TEMPFILE cannot be dropped at this time
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP_ORISSA_MASTER 4194304 6291456
    TEMP_ORISSA_BENCHMARK 680525824 0
    TEMP_ORISSA_TRANSACTION 37748736 67108864
    TIVOLIORTEMPTS 1048576 103809024
    MYTEMPFILE 11534336 1037041664
    5 rows selected.
    SQL> select STATUS,ENABLED,STATUS,BYTES/1024/1024 from v$tempfile;
    Etat ENABLED Etat BYTES/1024/1024
    OFFLIN READ WRITE OFFLIN 0
    ONLINE READ WRITE ONLINE 100
    ONLINE READ WRITE ONLINE 10
    ONLINE READ WRITE ONLINE 649
    ONLINE READ WRITE ONLINE 100
    ONLINE READ WRITE ONLINE 1000
    6 rows selected.
    SQL> desc v$tempfile;
    Name Null? Type
    FILE# NUMBER
    CREATION_CHANGE# NUMBER
    CREATION_TIME DATE
    TS# NUMBER
    RFILE# NUMBER
    STATUS VARCHAR2(7)
    ENABLED VARCHAR2(10)
    BYTES NUMBER
    BLOCKS NUMBER
    CREATE_BYTES NUMBER
    BLOCK_SIZE NUMBER
    NAME VARCHAR2(513)
    SQL> select file#,STATUS,ENABLED,STATUS,BYTES/1024/1024 from v$tempfile;
    FILE# Etat ENABLED Etat BYTES/1024/1024
    1 OFFLIN READ WRITE OFFLIN 0
    5 ONLINE READ WRITE ONLINE 100
    2 ONLINE READ WRITE ONLINE 10
    3 ONLINE READ WRITE ONLINE 649
    4 ONLINE READ WRITE ONLINE 100
    6 ONLINE READ WRITE ONLINE 1000
    6 rows selected.
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES;
    ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES
    ERROR at line 1:
    ORA-25152: TEMPFILE cannot be dropped at this time
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' offline;
    Database altered.
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES;
    ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES
    ERROR at line 1:
    ORA-25152: TEMPFILE cannot be dropped at this time
    SQL> select * from dba_temp_files;
    FILE_NAME FILE_ID TABLESPACE_NAME BYTES Blocks Etat RELATIVE_FNO AUT MAXBYTES MAXBLOCKS INCREMENT_BY
    USER_BYTES USER_BLOCKS
    G:\ORADATA\TEMP01.DBF 1 TEMP AVAILA
    J:\ORADATA\TIVOLIORTEMPTS.DBF 5 TIVOLIORTEMPTS 104857600 12,800 AVAILA 1 NO 0 0 0
    103809024 12672
    J:\ORADATA\TEMP_ORISSA_MASTER.TMP 2 TEMP_ORISSA_MASTER 10485760 1,280 AVAILA 1 YES 52428800 6400 128
    9437184 1152
    J:\ORADATA\TEMP_ORISSA_BENCHMARK.TMP 3 TEMP_ORISSA_BENCHMARK 680525824 83,072 AVAILA 1 YES 1073741824 131072 2
    679477248 82944
    J:\ORADATA\TEMP_ORISSA_TRANSACTION 4 TEMP_ORISSA_TRANSACTION 104857600 12,800 AVAILA 1 YES 1073741824 131072 2
    103809024 12672
    G:\ORADATA\TEMP001.DBF 6 MYTEMPFILE 1048576000 128,000 AVAILA 1 YES 2097152000 256000 1280
    1047527424 127872
    6 rows selected.
    SQL> select file#,STATUS,ENABLED,STATUS,BYTES/1024/1024 from v$tempfile;
    FILE# Etat ENABLED Etat BYTES/1024/1024
    1 OFFLIN READ WRITE OFFLIN 0
    5 ONLINE READ WRITE ONLINE 100
    2 ONLINE READ WRITE ONLINE 10
    3 ONLINE READ WRITE ONLINE 649
    4 ONLINE READ WRITE ONLINE 100
    6 ONLINE READ WRITE ONLINE 1000
    6 rows selected.
    SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;
    Database altered.
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP_ORISSA_MASTER 4194304 6291456
    TEMP_ORISSA_BENCHMARK 680525824 0
    TEMP_ORISSA_TRANSACTION 37748736 67108864
    TIVOLIORTEMPTS 1048576 103809024
    MYTEMPFILE 28311552 1020264448
    5 rows selected.
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' online;
    Database altered.
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP 3.4359E+10 0
    TEMP_ORISSA_MASTER 4194304 6291456
    TEMP_ORISSA_BENCHMARK 680525824 0
    TEMP_ORISSA_TRANSACTION 37748736 67108864
    TIVOLIORTEMPTS 1048576 103809024
    MYTEMPFILE 28311552 1020264448
    6 rows selected.
    SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE MYTEMPFILE;
    Database altered.
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES;
    ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES
    ERROR at line 1:
    ORA-25152: TEMPFILE cannot be dropped at this time
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' offline;
    Database altered.
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES;
    ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' DROP INCLUDING DATAFILES
    ERROR at line 1:
    ORA-25152: TEMPFILE cannot be dropped at this time
    SQL> ALTER DATABASE TEMPFILE 'G:\ORADATA\TEMP01.DBF' online;
    Database altered.
    SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;
    Database altered.
    SQL> select TABLESPACE_NAME, BYTES_USED, BYTES_FREE from V$TEMP_SPACE_HEADER;
    TABLESPACE_NAME BYTES_USED BYTES_FREE
    TEMP 3.4359E+10 0
    TEMP_ORISSA_MASTER 4194304 6291456
    TEMP_ORISSA_BENCHMARK 680525824 0
    TEMP_ORISSA_TRANSACTION 37748736 67108864
    TIVOLIORTEMPTS 1048576 103809024
    MYTEMPFILE 32505856 1016070144
    6 rows selected.
    SQL> exit
    I am not able to drop the Temp file as it is used by some users.
    When i checked my Alert Log then i am getting the ora-600 error....
    When i check metalink for this argument i found that its a bug in 91 &10gR2
    Please suggest some solution of this problem.
    Is it a serious issue of database.

    Robert Geier wrote:
    If you kill the sessions using the tempfile, or restart the database you may be able to drop it. Or you could try to shrink the tempfile instead of drop.
    Not sure why you are doing that though ? If the temp tablespace is full, check what is using the space, or add another tempfile to the tablespace.No I am not killing the sessions... But i just checked using following query that some users are using the temp Tablespace at that time. But i did not kill any session.
    select 'alter system kill session '''||a.sid||','||a.serial#||''' immediate;'
    from
    v$session a,
    v$sort_usage b,
    v$process c,
    v$parameter d
    where
    d.name = 'db_block_size'
    and
    a.saddr = b.session_addr
    and
    a.paddr = c.addr
    and
    b.tablespace='TEMP'
    and
    a.status='ACTIVE'
    order by
    b.tablespace,
    b.segfile#,
    b.segblk#,
    b.blocks;

  • Various Data DIctionary VIews

    After posting something here a few days back about the myriad views needing to be digested for the Fund.I Exam, I have just gleaned this lot from the Couchman book. No doubt some of the pros out there may well correct me, but this is simple what I have collected from the book, in the last 3 hours. Cheers.
    Dictionary Views
    Data Dictionary
    Which users are in the database password file:
    V$PWFILE_USERS
    Where values set in the init.ora file can be viewed – all parameters:
    V$PARAMETER
    Script used to create the objects that comprise the data dictionary:
    catalog.sql
    To grant a special role to users so they can look at DBA views:
    SELECT_CATALOG_ROLE
    Information about all database objects in the database:
    DBA_OBJECTS
    Information about all tables in the database:
    DBA_TABLES
    Information about all indexes in the database:
    DBA_INDEXES
    Information about all views (including dictionary views) in the database:
    DBA_VIEWS
    Information about all sequences in the database:
    DBA_SEQUENCES
    Information about all users in the database:
    DBA_USERS
    Information about all constraints in the database:
    DBA_CONSTRAINTS
    Information about all table columns that have constraints on them:
    DBA_CONS_COLUMNS
    Information about all columns that have indexes on them in the database:
    DBA_IND_COLUMNS
    Information about all columns in all the tables in the database:
    DBA_TAB_COLUMNS
    Information about all the roles in the database:
    DBA_ROLES
    Information about all object privileges in the database:
    DBA_TAB_PRIVS
    Information about all system privileges granted to all users in the database:
    DBA_SYS_PRIVS
    Displays all PL/SQL source code in the database:
    DBA_SOURCE
    Information about all triggers in the database:
    DBA_TRIGGERS
    Information about object privileges granted to roles
    ROLE_TAB_PRIVS
    Information about system privileges granted to roles
    ROLE_SYS_PRIVS
    Information about roles granted to roles
    ROLE_ROLE_PRIVS
    Information about all tablespaces in the database:
    DBA_TABLESPACES
    Information about all profiles in the database:
    DBA_PROFILES
    For all parameters?
    V$PARAMETER
    General information about the database mounted to your instance:
    V$DATABASE
    Most information about the performance of the database is kept here:
    V$SYSSTAT
    Most information about the performance for individual user sessions is stored here:
    V$SESSION , V$SESSTAT
    Information about online redo logs (2)
    V$LOG, V$LOGFILE
    Information about datafiles
    V$DATAFILE
    Basic information about control files, and the two columns it has:
    V$CONTROLFILE. STATUS / NAME
    An object you can query to obtain a listing of all data dictionary objects (4)
    CATALOG, CAT, DICTIONARY, DICT.
    When the control file was created, Sequence Number, most recent SCN:
    V$DATABASE
    Information stored in different sections of the control file, Sequence Number:
    V$CONTROLFILE_RECORD_SECTION
    To see the names and locations of all control files in the db? (2)
    V$PARAMETER. V$CONTROLFILE
    Tablespace and Datafiles
    Temporary Segments:
    Name, tablespace location, and owner of temporary segments:
    DBA_SEGMENTS
    Size of temporary tablespaces, current number of extents allocated to sort segments, and sort segment high-water mark information. Space usage allocation for temporary segments:
    V$SORT_SEGMENT
    Types of sorts that are happening currently on the database
    V$SORT_USAGE
    To see the username corresponding with the session:
    V$SESSION
    Information about every datafile in the database associated with a temporary tablespace:
    DBA_TEMP_FILES
    Similar to DBA_TEMP_FILES, this performance view gives Information about every datafile in the database associated with a temporary tablespace:
    V$TEMPFILE
    Storage Structures
    A summary view, contains all types of segments and their storage parameters, space utilization settings:
    DBA_SEGMENTS
    Tablespace quotas assigned to users:
    DBA_TS_QUOTAS
    Segment name, type, owner, total bytes of extent, name of tablespace storing the extent:
    DBA_EXTENTS
    The location and amount of free space by tablespace name:
    DBA_FREE_SPACE
    The location of free space in the tablespace that has been coalesced:
    DBA_FREE_SPACE_COALESCED
    Information about datafiles for every tablespace
    DBA_DATAFILES
    Performance view for information for datafiles for every tablespace
    V$DATAFILE
    To see the total amount of space allocated to a table?
    DBA_EXTENTS
    Table creation timestamp, information about the object ID:
    DBA_OBJECTS
    High water mark, all storage settings for a table, and statistics collected as part of the analyze (for row migration) operation on that table
    DBA_TABLES
    Information about every column in every table:
    DBA_TAB_COLUMNS
    To determine how many columns are marked unused for later removal?
    DBA_UNUSED_COL_TABS
    To find the number of deleted index entries ?
    INDEX_STATS
    To determine the columns on a table that have been indexed:
    DBA_ID_COLUMNS
    The dynamic view to show whether the index is being used in a meaningful way?
    V$OBJECT_USAGE
    To see whether a constraint exists on a particular column?
    DBA_CONS_COLUMNS
    To see the constraints associated with a particular table:
    DBA_CONSTRAINTS
    To find the username, ID number, (encrypted) password, default and temporary tablespace information, user profile of a user, password expiry date:
    DBA_USERS
    To all objects, which objects belong to which users, how many objects a user has created?
    DBA_OBJECTS
    Resource-usage parameters for a particular profile:
    DBA_PROFILES
    Identifies all resources in the database and their corresponding cost:
    RESOURCE_COST
    Identifies system resource limits for individual users:
    USER_RESOURCE_LIMITS
    Shows all system privileges:
    DBA_SYS_PRIVS
    Show all object privileges:
    DBA_TAB_PRIVS
    Shows all privileges in this session available to you as the current user:
    SESSION_PRIVS
    Views for audits currently taking place are created by this script:
    cataudit.sql
    a list of audit entries generated by the exists option of the audit command:
    DBA_AUDIT_EXISTS
    A list of audit entries generated for object audits:
    DBA_AUDIT_OBJECT
    A list of audit entries generated by session connects and disconnects:
    DBA_AUDIT_SESSION
    A list of audit entries generated by statement options of the audit command:
    DBA_AUDIT_STATEMENT
    A list of all entries in the AUD$ table collected by the audit command:
    DBA_AUDIT_TRAIL
    To determine the roles available in the database, the names of all the roles on the database and if a password is required to use each role:
    DBA_ROLES
    Names of all users and the roles granted to them:
    DBA_ROLE_PRIVS
    All the roles and the roles that are granted to them:
    ROLE_ROLE_PRIVS
    Which system privileges have been granted to a role:
    DBA_SYS_PRIVS
    All the system privileges granted only to roles:
    ROLE_SYS_PRIVS
    All the object privileges granted only to roles:
    ROLE_TAB_PRIVS
    All the roles available in the current session:
    SESSION_ROLES
    Which object privilege has been granted to a role:
    DBA_TAB_PRIVS
    To display the value of the NLS_CHARACTERSET parameter:
    NLS_DATABASE_PARAMETERS
    DA

    You can also find a lot of stuff by doing:
    SELECT *
    FROM dictionary;

  • Issue with to_number

    Hello all.
    Please explain me the following phenomena, i cant figure this out.
    Why is 'to_number' function forced by the optimizer in this query @ the operation number 11 ?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL>
    SQL>
    SQL>
    SQL> explain plan for
      2  with q as (
      3    select v$parameter.value bs_value
      4    from v$parameter
      5    where name='db_block_size'
      6  )
      7  select a.username,
      8         a.sid, a.serial#,
      9         round(((b.blocks*bs_value)/1024/1024),2) size_mb,
    10         a.status,
    11         b.segfile#,
    12         b.segblk#
    13  from v$session a,
    14       v$sort_usage b,
    15       v$process c,
    16       q
    17  where a.saddr = b.session_addr
    18    and a.paddr = c.addr
    19    and ((nvl(b.blocks,0)*nvl(bs_value,0))/1024/1024) > 0
    20  -- group by b.segfile#, b.segblk#,
    21  order by size_mb;
    Explained.
    SQL>
    SQL>
    SQL> set linesize 250
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3927520946
    | Id  | Operation                    | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                 |     1 |   668 |     3 (100)| 00:00:01 |
    |   1 |  SORT ORDER BY               |                 |     1 |   668 |     3 (100)| 00:00:01 |
    |   2 |   NESTED LOOPS               |                 |     1 |   668 |     2 (100)| 00:00:01 |
    |*  3 |    HASH JOIN                 |                 |     1 |   655 |     2 (100)| 00:00:01 |
    |*  4 |     HASH JOIN                |                 |     1 |   625 |     2 (100)| 00:00:01 |
    |   5 |      NESTED LOOPS            |                 |     1 |   509 |     1 (100)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |*  6 |       HASH JOIN              |                 |     1 |   496 |     1 (100)| 00:00:01 |
    |   7 |        NESTED LOOPS          |                 |     1 |   428 |     1 (100)| 00:00:01 |
    |*  8 |         HASH JOIN            |                 |     1 |   138 |     1 (100)| 00:00:01 |
    |*  9 |          FIXED TABLE FULL    | X$KSUSE         |     1 |    69 |     0   (0)| 00:00:01 |
    |* 10 |          FIXED TABLE FULL    | X$KTSSO         |     1 |    69 |     0   (0)| 00:00:01 |
    |* 11 |         FIXED TABLE FULL     | X$KSPPCV        |     5 |  1450 |     0   (0)| 00:00:01 |
    |* 12 |        FIXED TABLE FULL      | X$KSPPI         |     1 |    68 |     0   (0)| 00:00:01 |
    |* 13 |       FIXED TABLE FIXED INDEX| X$KSLED (ind:2) |     1 |    13 |     0   (0)| 00:00:01 |
    |* 14 |      FIXED TABLE FULL        | X$KSUSE         |     1 |   116 |     0   (0)| 00:00:01 |
    |* 15 |     FIXED TABLE FULL         | X$KSUPR         |     1 |    30 |     0   (0)| 00:00:01 |
    |* 16 |    FIXED TABLE FIXED INDEX   | X$KSLED (ind:2) |     1 |    13 |     0   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - access("S"."KSUSEPRO"="ADDR")
       4 - access("S"."ADDR"="KTSSOSES")
       6 - access("X"."INDX"="Y"."INDX")
           filter(TRANSLATE("KSPPINM",'_','#') NOT LIKE '#%' OR "KSPPSTDF"='FALSE' OR
                  BITAND("KSPPSTVF",5)>0)
       8 - access("KTSSOSES"="S"."ADDR" AND "KTSSOSNO"="S"."KSUSESER")
    PLAN_TABLE_OUTPUT
       9 - filter("S"."INST_ID"=USERENV('INSTANCE') AND BITAND("S"."KSSPAFLG",1)<>0 AND
                  BITAND("S"."KSUSEFLG",1)<>0)
      10 - filter("X$KTSSO"."INST_ID"=USERENV('INSTANCE'))
      11 - filter(NVL("KTSSOBLKS",0)*TO_NUMBER(NVL("KSPPSTVL",'0'))/1024/1024>0)
      12 - filter("KSPPINM"='db_block_size' AND "X"."INST_ID"=USERENV('INSTANCE') AND
                  TRANSLATE("KSPPINM",'_','#') NOT LIKE '##%')
      13 - filter("S"."KSUSEOPC"="E"."INDX")
      14 - filter("S"."INST_ID"=USERENV('INSTANCE') AND BITAND("S"."KSSPAFLG",1)<>0 AND
                  BITAND("S"."KSUSEFLG",1)<>0)
      15 - filter("INST_ID"=USERENV('INSTANCE') AND BITAND("KSSPAFLG",1)<>0)
      16 - filter("S"."KSUSEOPC"="E"."INDX")
    44 rows selected.

    Actually I can reproduce, when hardcoding block size the query runs ok, but the other version keeps on ending up in an error:
    SQL>   select a.username,
      2           a.sid, a.serial#,
      3           (b.blocks * 8192)/1024/1024 size_mb,
      4           a.status,
      5           b.segfile#,
      6           b.segblk#
      7    from v$session a,
      8         v$sort_usage b,
      9         v$process c
    10    where a.saddr = b.session_addr
    11      and a.paddr = c.addr
    12      and (b.blocks * 8192)/1024/1024 > 0;
    USERNAME                              SID    SERIAL#    SIZE_MB STATUS     SEGFILE#    SEGBLK#
    *********                             254       6958          1 INACTIVE        201      33280
    *********                             254       6958          1 INACTIVE        201      33664
    2 rows selected.
    SQL>  with q as (
      2    select v$parameter.value bs_value
      3    from v$parameter
      4    where name='db_block_size'
      5  )
      6  select a.username,
      7         a.sid, a.serial#,
      8         round(((b.blocks*bs_value)/1024/1024),2) size_mb,
      9         a.status,
    10         b.segfile#,
    11         b.segblk#
    12  from v$session a,
    13       v$sort_usage b,
    14       v$process c,
    15       q
    16  where a.saddr = b.session_addr
    17    and a.paddr = c.addr
    18    and ((nvl(b.blocks,0)*nvl(bs_value,0))/1024/1024) > 0;
      and ((nvl(b.blocks,0)*nvl(bs_value,0))/1024/1024) > 0
    ERROR at line 18:
    ORA-01722: invalid number
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      ProductionNow I've been fiddling with the query, adding to_number, omitting nvl etc. etc., but I keep on getting invalid number,. no matter what...
    This is either very weird or I'm missing something very obvious here.. ?:|

  • Oracle 11g - Memory used for sorting

    Hi everyone,
    I would like to know how I could analyze memory used for sorting in Oracle 11g. When I run the below query, it returns 1531381.
    select value from v$sysstat where name like 'sorts (memory)';But when I check sort_area_size parameter from v$parameter, it returns 65536. Does it mean my database is using more memory for sorting than sort_area_size. Or is the way I interpret v$sysstat view and sort_area_size wrong? What is the best way to monitor the memory usage for sorting? Thanks in advance.
    Regards,
    K.H
    Edited by: K Hein on Apr 5, 2012 8:16 PM

    check the valuse of pga_aggregate_target
    http://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams157.htm
    Note:
    Oracle does not recommend using the SORT_AREA_SIZE parameter unless the instance is configured with the shared server option. Oracle recommends that you enable automatic sizing of SQL working areas by setting PGA_AGGREGATE_TARGET instead. SORT_AREA_SIZE is retained for backward compatibility.
    What is the best way to monitor the memory usage for sorting? try v$sort_usage
    or v$tempseg_usage
    col sid_serial for a44
    col size for a22
    col SID_SERIAL for a22
    SELECT b.tablespace,
            ROUND(((b.blocks*p.value)/1024/1024),2)||' MB' "SIZE",
            a.sid||','||a.serial# SID_SERIAL,
            a.username,a.osuser,
            a.program
       FROM sys.v_$session a,
            sys.v_$sort_usage b,
            sys.v_$parameter p
      WHERE p.name  = 'db_block_size'
        AND a.saddr = b.session_addr
    ORDER BY b.blocks;

  • Can any one validate the below queries related to temp tablespace

    For Temporary Tablespace Free and Used Space Information, I am using the following query
    SELECT fs.tablespace_name tspace,
    sum(fs.bytes)/(1024*1024) tot_ts_size_MB,
    sum(df.bytes_free)/(1024*1024) free_ts_size_MB,
    sum(df.bytes_used)/(1024*1024) used_ts_size_MB
    FROM dba_temp_files fs,
    (select tablespace_name, bytes_free, bytes_used from v$temp_space_header) df
    WHERE fs.tablespace_name(+) = df.tablespace_name
    GROUP BY fs.tablespace_name;
    For getting how much space is being used by current users, I am using the following query
    SELECT b.tablespace tablespace_name,
    a.sid sid,
    a.username username,
    (b.blocks * c.value)/(1024*1024) Current_Usage
    FROM v$session a, v$sort_usage b,
    (select value from v$parameter where name = 'db_block_size') c
    WHERE a.saddr = b.session_addr;
    Can any one validate, that above queries are right or not?

    Hi,
    1.for first query i think u can also use only v$temp_Space_header to find out
    the required details by
    SELECT tablespace_name, SUM(bytes_used)/1024/1024 "Tot Used Space in MB",
    SUM(bytes_free)/1024/1024 "Tot Free Space in MB"
    FROM V$temp_space_header
    GROUP BY tablespace_name;
    2.http://www.dbazine.com/oracle/or-articles/weeg3
    Thanks
    Kuljeet

  • Abcdef

    to_date('03-23-2010','mm-dd-yyyy')
    to_date('2008-06-08','yyyy-mm-dd')
    DBMS_OUTPUT.PUT_LINE(' 4th Where clause: ' || WHERE_CLAUSE);
    HKey_Local Machine -> Software -> Microsoft -> MSLicensing
    topas
    Removing batch of Files in linux:
    =====================================
    find . -name "*.arc" -mtime +20 -exec rm -f {} \;
    find . -name "*.dbf" -mtime +60 -exec mv {} /backup/Arch_Bkp_02May11/ \;
    ALTER DATABASE
    SET STANDBY DATABASE TO MAXIMIZE {AVAILABILITY | PERFORMANCE | PROTECTION};
    ================================================================================
    Find top N records:
    ===================
    select * from (select ename from emp order by sal)
    where rownum <=n;
    Find top Nth record: (n=0 for 1st highest)
    =========================================
    select * from emp a
    where (n =
    (select count(distinct b.sal) from emp b
    where b.sal > a.sal));
    Query for Listing last n records from the table
    =================================================
    select * from (select * from emp order by rownum desc) where rownum<4
    HOW TO tablespace wise and file wise info
    ============================
    col file_name for a45
    col tablespace_name for a15
    set linesize 132
    select a.tablespace_name,a.file_name,a.AUTOEXTENSIBLE,----a.status,
    round(a.bytes/1024/1024,2) Total_MB,
    round(sum(b.bytes)/1024/1024,2) Free_MB,
    round((a.bytes/1024/1024 - sum(b.bytes)/1024/1024),2) Used_MB
    from dba_data_files a,dba_free_space b
    where a.file_id=b.file_id
    and a.tablespace_name=b.tablespace_name
    group by a.tablespace_name,b.file_id,a.file_name,a.bytes,a.AUTOEXTENSIBLE--,a.status
    order by tablespace_name;
    col tablespace_name for a15
    SELECT tablespace_name,ts_#,num_files,sum_free_mbytes,count_blocks,max_mbytes,
    sum_alloc_mbytes,DECODE(sum_alloc_mbytes,0,0,100 * sum_free_mbytes /sum_alloc_mbytes ) AS pct_free
    FROM (SELECT v.name AS tablespace_name,ts# AS ts_#,
    NVL(SUM(bytes)/1048576,0) AS sum_alloc_mbytes,
    NVL(COUNT(file_name),0) AS num_files
    FROM dba_data_files f,v$tablespace v
    WHERE v.name = f.tablespace_name (+)
    GROUP BY v.name,ts#),
    (SELECT v.name AS fs_ts_name,ts#,NVL(MAX(bytes)/1048576,0) AS max_mbytes,
    NVL(COUNT(BLOCKS) ,0) AS count_blocks,
    NVL(SUM(bytes)/1048576,0) AS sum_free_mbytes
    FROM dba_free_space f,v$tablespace v
    WHERE v.name = f.tablespace_name(+)
    GROUP BY v.name,ts#)
    WHERE tablespace_name = fs_ts_name
    ORDER BY tablespace_name;
    ==================================
    col file_name for a45
    col tablespace_name for a15
    set linesize 132
    select a.tablespace_name,a.file_name,a.AUTOEXTENSIBLE,----a.status,
    round(a.bytes/1024/1024,2) Total_MB,
    round(sum(b.bytes)/1024/1024,2) Free_MB,
    round((a.bytes/1024/1024 - sum(b.bytes)/1024/1024),2) Used_MB
    from dba_data_files a,dba_free_space b
    where a.file_id=b.file_id
    and a.tablespace_name=b.tablespace_name
    group by a.tablespace_name,b.file_id,a.file_name,a.bytes,a.AUTOEXTENSIBLE--,a.status
    order by file_name;
    =============================================================
    HOW TO FIND CHILD TABLES
    ===========================================
    col column_name for a30
    col owner for a10
    set linesize 132
    select --a.table_name parent_table,
    b.owner,
    b.table_name child_table
    , a.constraint_name , b.constraint_name
    from dba_constraints a ,dba_constraints b
    where a.owner='LEIQA20091118'
    and a.constraint_name = b.r_constraint_name
    --and b.constraint_type = 'R'
    and a.constraint_type IN ('P','U')
    and a.table_name =upper('&tabname');
    List foreign keys and referenced table and columns:
    ======================================================
    SELECT DECODE(c.status,'ENABLED','C','c') t,
    SUBSTR(c.constraint_name,1,31) relation,
    SUBSTR(cc.column_name,1,24) columnname,
    SUBSTR(p.table_name,1,20) tablename
    FROM user_cons_columns cc, user_constraints p,
    user_constraints c
    WHERE c.table_name = upper('&table_name')
    AND c.constraint_type = 'R'
    AND p.constraint_name = c.r_constraint_name
    AND cc.constraint_name = c.constraint_name
    AND cc.table_name = c.table_name
    UNION ALL
    SELECT DECODE(c.status,'ENABLED','P','p') t,
    SUBSTR(c.constraint_name,1,31) relation,
    SUBSTR(cc.column_name,1,24) columnname,
    SUBSTR(c.table_name,1,20) tablename
    FROM user_cons_columns cc, user_constraints p,
    user_constraints c
    WHERE p.table_name = upper('PERSON')
    AND p.constraint_type in ('P','U')
    AND c.r_constraint_name = p.constraint_name
    AND c.constraint_type = 'R'
    AND cc.constraint_name = c.constraint_name
    AND cc.table_name = c.table_name
    ORDER BY 1, 4, 2, 3
    List a child table's referential constraints and their associated parent table:
    ==============================================================
    SELECT t.owner CHILD_OWNER,
    t.table_name CHILD_TABLE,
    t.constraint_name FOREIGN_KEY_NAME,
    r.owner PARENT_OWNER,
    r.table_name PARENT_TABLE,
    r.constraint_name PARENT_CONSTRAINT
    FROM user_constraints t, user_constraints r
    WHERE t.r_constraint_name = r.constraint_name
    AND t.r_owner = r.owner
    AND t.constraint_type='R'
    AND t.table_name = <child_table_name>;
    parent tables:
    ================
    select constraint_name,constraint_type,r_constraint_name
    from dba_constraints
    where table_name ='TM_PAY_BILL'
    and constraint_type in ('R');
    select CONSTRAINT_NAME,TABLE_NAME,COLUMN_NAME from user_cons_columns where table_name='FS_FR_TERMINALLOCATION';
    select a.OWNER,a.TABLE_NAME,a.CONSTRAINT_NAME,a.CONSTRAINT_TYPE
    ,b.COLUMN_NAME,b.POSITION
    from dba_constraints a,dba_cons_columns b
    where a.CONSTRAINT_NAME=b.CONSTRAINT_NAME
    and a.TABLE_NAME=b.TABLE_NAME
    and a.table_name=upper('TM_GEN_INSTRUCTION')
    and a.constraint_type in ('P','U');
    select constraint_name,constraint_type,r_constraint_name
    from dba_constraints
    where table_name ='TM_PAY_BILL'
    and constraint_type in ('R');
    ===============================================
    HOW TO FIND INDEXES
    =====================================
    col column_name for a30
    col owner for a25
    select a.owner,a.index_name, --a.table_name,a.tablespace_name,
    b.column_name,b.column_position
    from dba_indexes a,dba_ind_columns b
    where a.owner='SCE'
    and a.index_name=b.index_name
    and a.table_name = upper('&tabname')
    order by a.index_name,b.column_position;
    col column_name for a40
    col index_owner for a15
    select index_owner,index_name,column_name,
    column_position from dba_ind_columns
    where table_owner= upper('VISILOGQA19') and table_name ='TBLTRANSACTIONGROUPMAIN';
    -- check for index on FK
    ===============================
    set linesize 121
    col status format a6
    col columns format a30 word_wrapped
    col table_name format a30 word_wrapped
    SELECT DECODE(b.table_name, NULL, 'Not Indexed', 'Indexed' ) STATUS, a.table_name, a.columns, b.columns from (
    SELECT SUBSTR(a.table_name,1,30) table_name,
    SUBSTR(a.constraint_name,1,30) constraint_name, MAX(DECODE(position, 1,
    SUBSTR(column_name,1,30),NULL)) || MAX(DECODE(position, 2,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 3,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 4,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 5,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 6,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 7,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 8,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position, 9,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,10,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,11,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,12,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,13,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,14,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,15,', '|| SUBSTR(column_name,1,30),NULL)) || max(DECODE(position,16,', '|| SUBSTR(column_name,1,30),NULL)) columns
    from user_cons_columns a, user_constraints b
    WHERE a.constraint_name = b.constraint_name
    AND constraint_type = 'R'
    GROUP BY SUBSTR(a.table_name,1,30), SUBSTR(a.constraint_name,1,30) ) a, (
    SELECT SUBSTR(table_name,1,30) table_name,
    SUBSTR(index_name,1,30) index_name, MAX(DECODE(column_position, 1,
    SUBSTR(column_name,1,30),NULL)) || MAX(DECODE(column_position, 2,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 3,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 4,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 5,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 6,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 7,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 8,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position, 9,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,10,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,11,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,12,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,13,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,14,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,15,', '||SUBSTR(column_name,1,30),NULL)) || max(DECODE(column_position,16,', '||SUBSTR(column_name,1,30),NULL)) columns
    from user_ind_columns group by SUBSTR(table_name,1,30), SUBSTR(index_name,1,30) ) b
    where a.table_name = b.table_name (+) and b.columns (+) like a.columns || '%';
    ==================================================
    HOW TO FIND unique keys
    ===========================
    col column_name for a30
    col owner for a10
    set linesize 132
    select a.owner , --a.table_name,
    a.constraint_name,a.constraint_type,
    b.column_name,b.position
    from dba_constraints a, dba_cons_columns b
    where a.table_name = upper('&tabname')
    and a.constraint_name = b.constraint_name
    and a.constraint_type in ('P','U')
    and a.owner=b.owner
    order by a.owner,a.constraint_name,b.position;
    ==================================
    HOW TO FIND ROWlocks
    ======================
    col object_name for a30
    col terminal for a20
    set linesize 1000
    col spid for a10
    col osuser for a15
    select to_char(logon_time,'DD-MON-YYYY HH24:MI:SS'),OSUSER,--owner,
    s.sid, s.serial#,p.spid,
    s.terminal,l.locked_mode,o.object_name,l.ORACLE_USERNAME --,o.object_type
    from v$session s, dba_objects o,v$locked_object l, V$process p
    where o.object_id=l.object_id
    and s.sid=l.session_id
    and s.paddr=p.addr
    order by logon_time;
    SELECT OWNER||'.'||OBJECT_NAME AS Object, OS_USER_NAME, ORACLE_USERNAME,
    PROGRAM, NVL(lockwait,'ACTIVE') AS Lockwait,DECODE(LOCKED_MODE, 2,
    'ROW SHARE', 3, 'ROW EXCLUSIVE', 4, 'SHARE', 5,'SHARE ROW EXCLUSIVE',
    6, 'EXCLUSIVE', 'UNKNOWN') AS Locked_mode, OBJECT_TYPE, SESSION_ID, SERIAL#, c.SID
    FROM SYS.V_$LOCKED_OBJECT A, SYS.ALL_OBJECTS B, SYS.V_$SESSION c
    WHERE A.OBJECT_ID = B.OBJECT_ID AND C.SID = A.SESSION_ID
    ORDER BY Object ASC, lockwait DESC;
    SELECT DECODE(request,0,'Holder: ','Waiter: ')||sid sess,
    id1, id2, lmode, request, type
    FROM V$LOCK
    WHERE (id1, id2, type) IN
    (SELECT id1, id2, type FROM V$LOCK WHERE request>0)
    ORDER BY id1, request;
    find locks
    =====================
    set linesize 1000
    SELECT --osuser,
    a.username,a.serial#,a.sid,--a.terminal,
    sql_text
    from v$session a, v$sqltext b, V$process p
    where a.sql_address =b.address
    and a.paddr = p.addr
    and p.spid = '&os_pid'
    order by address, piece;
    select sql_text
    from V$sqltext_with_newlines
    where address =
    (select prev_sql_addr
    from V$session
    where username = :uname and sid = :snum) ORDER BY piece
    set pagesize 50000
    set linesize 30000
    set long 500000
    set head off
    select s.username su,s.sid,s.serial#,substr(sa.sql_text,1,540) txt
    from v$process p,v$session s,v$sqlarea sa
    where p.addr=s.paddr
    and s.username is not null
    and s.sql_address=sa.address(+)
    and s.sql_hash_value=sa.hash_value(+)
    and spid=&SPID;
    privileges
    ===========
    select * from dba_sys_privs where grantee = 'SCE';
    select * from dba_role_privs where grantee = 'SCE'
    select * from dba_sys_privs where grantee in ('CONNECT','APPL_CONNECT');
    Check high_water_mark_statistics
    ===================================
    select * from DBA_HIGH_WATER_MARK_STATISTICS;
    Multiple Blocksizes:
    =========================
    alter system set db_16k_cache_size=64m;
    create tablespace index_ts datafile '/data1/index_ts01.dbf' size 10240m blocksize 16384;
    11g default profiles:
    ========================
    alter profile default limit password_lock_time unlimited;
    alter profile default limit password_life_time unlimited;
    alter profile default limit password_grace_time unlimited;
    logfile switch over:
    select GROUP#,THREAD#,SEQUENCE#,BYTES,MEMBERS,ARCHIVED,
    STATUS,to_char(FIRST_TIME,'DD-MON-YYYY HH24:MI:SS') switch_time
    from v$log;
    Temporary tablespace usage:
    ============================
    SELECT b.tablespace,
    ROUND(((b.blocks*p.value)/1024/1024),2)||'M' "SIZE",
    a.sid||','||a.serial# SID_SERIAL,
    a.username,
    a.program
    FROM sys.v_$session a,
    sys.v_$sort_usage b,
    sys.v_$parameter p
    WHERE p.name = 'db_block_size'
    AND a.saddr = b.session_addr
    ORDER BY b.tablespace, b.blocks;
    SELECT A2.TABLESPACE, A2.SEGFILE#, A2.SEGBLK#, A2.BLOCKS,
    A1.SID, A1.SERIAL#, A1.USERNAME, A1.OSUSER, A1.STATUS
    FROM V$SESSION A1,V$SORT_USAGE A2 WHERE A1.SADDR = A2.SESSION_ADDR;
    ========================================
    ALTER SYSTEM KILL SESSION 'SID,SERIAL#';
    Inactive sessions killing:
    SELECT 'ALTER SYSTEM KILL SESSION ' || '''' || SID || ',' ||
    serial# || '''' || ' immediate;' text
    FROM v$session
    WHERE status = 'INACTIVE'
    AND last_call_et > 86400
    AND username IN (SELECT username FROM DBA_USERS WHERE user_id>56);
    Procedure:
    CREATE OR REPLACE PROCEDURE Inactive_Session_Cleanup AS
    BEGIN
    FOR rec_session IN (SELECT 'ALTER SYSTEM KILL SESSION ' || '''' || SID || ',' ||
    serial# || '''' || ' immediate' text
    FROM v$session
    WHERE status = 'INACTIVE'
    AND last_call_et > 43200
    AND username IN (SELECT username FROM DBA_USERS WHERE user_id>60)) LOOP
    EXECUTE IMMEDIATE rec_session.text;
    END LOOP;
    END Inactive_Session_Cleanup;
    sequence using plsql
    =========================
    Declare
    v_next NUMBER;
    script varchar2(5000);
    BEGIN
    SELECT (MAX(et.dcs_code) + 1) INTO v_next FROM et_document_request et;
    script:= 'CREATE SEQUENCE et_document_request_seq
    MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH '||
         v_next || ' INCREMENT BY 1 CACHE 20';
    execute immediate script;
    end;
    ===========================
    Terminal wise session
    select TERMINAL,count(*) from v$session
    group by TERMINAL;
    total sessions
    select count(*) from v$session
    where TERMINAL not like '%UNKNOWN%'
    and TERMINAL is not null;
    HOW TO FIND DUPLICATE TOKEN NUMBERS
    ===========================================
    select count(distinct a.token_number) dup
    from tm_pen_bill a,tm_pen_bill b
    where a.token_number = b.token_number
    and a.bill_number <> b.bill_number
    and a.token_number is not null;
    when Block Corruption occurs:
    select * from DBA_EXTENTS
    WHERE file_id = '13' AND block_id BETWEEN '44157' and '50649';
    select BLOCK_ID,SEGMENT_NAME,BLOCKS from dba_extents where FILE_ID='14'
    and BLOCK_ID like '%171%';
    select BLOCK_ID,SEGMENT_NAME,BLOCKS from dba_extents where FILE_ID='14'
    and SEGMENT_NAME = 'TEMP_TD_PAY_ALLOTMENT_NMC';
    DBVERIFY:
    dbv blocksize=8192 file=users01.dbf log=dbv_users01.log
    ==============================================================
    DBMS_REPAIR:(Block Corruption)
    exec dbms_repair.admin_tables(table_name=>'REPAIR_TABLE',table_type=>dbms_repair.repair_table,action=>dbms_repair.create_action,tablespace=>'USERS');
    variable v_corrupt_count number;
    exec dbms_repair.check_object('scott','emp',corrupt_count=>:v_corrupt_count);
    print v_corrupt_count;
    ==============================================================
    Password:
    select login,substr(utl_raw.cast_to_varchar2(utl_raw.cast_to_varchar2(password)),1,30) password
    from mm_gen_user where active_flag = 'Y' and user_id=64 and LOGIN='GOPAL' ;
    CHARACTERSET
    select * from NLS_DATABASE_PARAMETERS;
    SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;
    select value from nls_database_parameters where parameter='NLS_CHARACTERSET';
    ==========================================================
    EXPLAIN PLAN TABLE QUERY
    ========================
    EXPLAIN PLAN SET STATEMENT_ID='5'
    FOR
    "DML STATEMENT"
    PLAN TABLE QUERY
    ===============================
    set linesize 1000
    set arraysize 1000
    col OBJECT_TYPE for a20
    col OPTIMIZER for a20
    col object_name for a30
    col options for a25
    select COST,OPERATION,OPTIONS,OBJECT_TYPE,
    OBJECT_NAME,OPTIMIZER
    --,ID,PARENT_ID,POSITION,CARDINALITY
    from plan_table
    where statement_id='&statement_id';
    Rman settings: disk formats
    %t represents a timestamp
    %s represents the backup set number
    %p represents the piece number
    The dbms_workload_repository.create_snapshot procedure creates a manual snapshot in the AWR as seen in this example:
    EXEC dbms_workload_repository.create_snapshot;
    Calculation of a table the size of the space occupied by
    ========================================================
    select owner, table_name,
    NUM_ROWS,
    BLOCKS * AAA/1024/1024 "Size M",
    EMPTY_BLOCKS,
    LAST_ANALYZED
    from dba_tables
    where table_name = 'XXX';
    Finding statement/s which use lots of shared pool memory:
    ==========================================================
    SELECT substr(sql_text,1,40) "SQL", count(*) , sum(executions) "TotExecs"
    FROM v$sqlarea
    WHERE executions < 5
    GROUP BY substr(sql_text,1,40)
    HAVING count(*) > 30
    ORDER BY 2;
    See a table size table
    =========================================
    select sum (bytes) / (1024 * 1024) as "size (M)" from user_segments
    where segment_name = upper ('& table_name');
    See a index size table
    =========================================
    select sum (bytes) / (1024 * 1024) as "size (M)" from user_segments
    where segment_name = upper ('& index_name');
    monitoring table space I / O ratio
    ====================================
    select B.tablespace_name name, B.file_name "file", A.phyrds pyr,
    A.phyblkrd pbr, A.phywrts pyw, A.phyblkwrt pbw
    from v $ filestat A, dba_data_files B
    where A.file # = B.file_id
    order by B.tablespace_name;
    monitor the file system I / O ratio
    =====================================
    select substr (C.file #, 1,2) "#", substr (C.name, 1,30) "Name",
    C.status, C.bytes, D.phyrds, D.phywrts
    from v $ datafile C, v $ filestat D
    where C.file # = D.file #;
    the hit rate monitor SGA
    =========================
    select a.value + b.value "logical_reads", c.value "phys_reads",
    round (100 * ((a.value + b.value)-c.value) / (a.value + b.value)) "BUFFER HIT RATIO"
    from v $ sysstat a, v $ sysstat b, v $ sysstat c
    where a.statistic # = 38 and b.statistic # = 39
    and c.statistic # = 40;
    monitoring SGA in the dictionary buffer hit ratio
    ==================================================
    select parameter, gets, Getmisses, getmisses / (gets + getmisses) * 100 "miss ratio",
    (1 - (sum (getmisses) / (sum (gets) + sum (getmisses ))))* 100 "Hit ratio"
    from v $ rowcache
    where gets + getmisses <> 0
    group by parameter, gets, getmisses;
    monitoring SGA shared cache hit ratio should be less than 1%
    =============================================================
    select sum (pins) "Total Pins", sum (reloads) "Total Reloads",
    sum (reloads) / sum (pins) * 100 libcache
    from v $ librarycache;
    select sum (pinhits-reloads) / sum (pins) "hit radio", sum (reloads) / sum (pins) "reload percent"
    from v $ librarycache;
    monitoring SGA in the redo log buffer hit ratio should be less than 1%
    =========================================================================
    SELECT name, gets, misses, immediate_gets, immediate_misses,
    Decode (gets, 0,0, misses / gets * 100) ratio1,
    Decode (immediate_gets + immediate_misses, 0,0,
    immediate_misses / (immediate_gets + immediate_misses) * 100) ratio2
    FROM v $ latch WHERE name IN ('redo allocation', 'redo copy');
    control memory and hard disk sort ratio, it is best to make it smaller than .10, an increase sort_area_size
    =============================================================================================================
    SELECT name, value FROM v$sysstat WHERE name IN ('sorts (memory)', 'sorts (disk)');
    monitoring what the current database who are running SQL statements?
    ===================================================================
    SELECT osuser, username, sql_text from v $ session a, v $ sqltext b
    where a.sql_address = b.address order by address, piece;
    monitoring the dictionary buffer?
    =====================================
    SELECT (SUM (PINS - RELOADS)) / SUM (PINS) "LIB CACHE" FROM V $ LIBRARYCACHE;
    SELECT (SUM (GETS - GETMISSES - USAGE - FIXED)) / SUM (GETS) "ROW CACHE" FROM V $ ROWCACHE;
    SELECT SUM (PINS) "EXECUTIONS", SUM (RELOADS) "CACHE MISSES WHILE EXECUTING" FROM V $ LIBRARYCACHE;
    The latter divided by the former, this ratio is less than 1%, close to 0% as well.
    SELECT SUM (GETS) "DICTIONARY GETS", SUM (GETMISSES) "DICTIONARY CACHE GET MISSES"
    FROM V $ ROWCACHE
    see the table a high degree of fragmentation?
    =================================================
    SELECT owner,segment_name table_name, COUNT (*) extents
    FROM dba_segments WHERE owner NOT IN ('SYS', 'SYSTEM') GROUP BY owner,segment_name
    HAVING COUNT (*) = (SELECT MAX (COUNT (*)) FROM dba_segments GROUP BY segment_name);
    =======================================================================
    Fragmentation:
    =================
    select table_name,round((blocks*8),2)||'kb' "size"
    from user_tables
    where table_name = 'BIG1';
    Actual Data:
    =============
    select table_name,round((num_rows*avg_row_len/1024),2)||'kb' "size"
    from user_tables
    where table_name = 'BIG1';
    The establishment of an example data dictionary view to 8I
    =======================================================
    $ ORACLE_HOME / RDBMS / ADMIN / CATALOG.SQL
    The establishment of audit data dictionary view with an example to 8I
    ======================================================
    $ ORACLE_HOME / RDBMS / ADMIN / CATAUDIT.SQL
    To establish a snapshot view using the data dictionary to 8I Case
    =====================================================
    $ ORACLE_HOME / RDBMS / ADMIN / CATSNAP.SQL
    The table / index moving table space
    =======================================
    ALTER TABLE TABLE_NAME MOVE TABLESPACE_NAME;
    ALTER INDEX INDEX_NAME REBUILD TABLESPACE TABLESPACE_NAME;
    How can I know the system's current SCN number?
    =================================================
    select max (ktuxescnw * power (2, 32) + ktuxescnb) from x$ktuxe;
    Will keep a small table into the pool
    ======================================
    alter table xxx storage (buffer_pool keep);
    Check the permissions for each user
    ===================================
    SELECT * FROM DBA_SYS_PRIVS;
    =====================================================================
    Tablespace auto extend check:
    =================================
    col file_name for a50
    select FILE_NAME,TABLESPACE_NAME,AUTOEXTENSIBLE from dba_data_files
    order by TABLESPACE_NAME;
    COL SEGMENT_NAME FOR A30
    select SEGMENT_NAME,TABLESPACE_NAME,BYTES,EXTENTS,INITIAL_EXTENT,
    NEXT_EXTENT,MAX_EXTENTS,PCT_INCREASE
    from user_segments
    where segment_name in ('TD_PAY_CHEQUE_PREPARED','TM_PAY_BILL','TD_PAY_PAYORDER');
    select TABLESPACE_NAME,INITIAL_EXTENT,NEXT_EXTENT,MAX_EXTENTS,PCT_INCREASE
    from dba_tablespaces;
    alter tablespace temp default storage(next 5m maxextents 20480 pctincrease 0);
    ALTER TABLE TD_PAY_CHEQUE_PREPARED
    default STORAGE ( NEXT 10 M maxextents 20480 pctincrease 0);
    Moving table from one tablespace to another
    ===============================================
    alter table KHAJANE.TEMP_TM_PAY_ALLOTMENT_NMC move tablespace khajane_ts;
    ==============================================
    for moving datafiles location:
    ========================================
    alter database rename file a to b;
    ======================================================================
    for logfile Clearence:
    select * from global_name;
    col member for a50
    set linesize 132
    set trimspool on
    select 'alter database clear logfile ' || '''' || member || '''' || ';'
    from v$logfile where status ='STALE';
    logfile switch over:
    select GROUP#,THREAD#,SEQUENCE#,BYTES,MEMBERS,ARCHIVED,
    STATUS,to_char(FIRST_TIME,'DD-MON-YYYY HH24:MI:SS') switch_time
    from v$log;

    Answered

  • Using sql to monitor free/used space

    Hi,
    Using the next sql statement
    SELECT /* + RULE */  df.tablespace_name "Tablespace",
           df.bytes / (1024 * 1024) "Size (MB)",
           SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
           Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
           Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
      FROM dba_free_space fs,
           (SELECT tablespace_name,SUM(bytes) bytes
              FROM dba_data_files
             GROUP BY tablespace_name) df
    WHERE fs.tablespace_name (+)  = df.tablespace_name
    GROUP BY df.tablespace_name,df.bytes
    UNION ALL
    SELECT /* + RULE */ df.tablespace_name tspace,
           fs.bytes / (1024 * 1024),
           SUM(df.bytes_free) / (1024 * 1024),
           Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
           Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
      FROM dba_temp_files fs,
           (SELECT tablespace_name,bytes_free,bytes_used
              FROM v$temp_space_header
             GROUP BY tablespace_name,bytes_free,bytes_used) df
    WHERE fs.tablespace_name (+)  = df.tablespace_name
    GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
    ORDER BY 4 DESC;from the source
    http://www.orafaq.com/wiki/Tablespacethe output is
    Tablespace                     Size (MB)              Free (MB)              % Free                 % Used                
    TS_UNDO                        4000                   3973,875               99                     1                     
    SYSAUX                         512                    293,5625               57                     43                    
    SYSTEM                         512                    224,3125               44                     56                    
    DATA                           70000                  24346,375              35                     65                    
    TS_TEMP                        5000                   460                    9                      91                    
    INDX                           30000                  2349,0625              8                      92why doesn't have the ts_temp tablespace almost free space?
    becouse if I use the management database sql developer option the ts_temp output is
    Tablespace                     Size (MB)              Free (MB)              % Free                 % Used                
    TS_TEMP                        null                    0                      null                  nullthanks in advanced

    The first half of your query seems to work -- just keep in mind that is doesn't consider that the tablespace datafiles might be auto-extendable up to some limit.
    The second half doesn't seem to work (I'm in 11g).
    Here's what I use to look at temp-space totals:
    select  f.tblspc  as "Tablespace"
         ,  nvl( sum( s.blocks * b.value ), 0 )  as "Bytes-Used"
         ,  f.bytes  as "Bytes-Available"
         ,  round( nvl( sum( s.blocks * b.value ), 0 ) / f.bytes * 100, 2 )  as "%-Used"
      from  ( select  tablespace_name       as tblspc
                   ,  sum(bytes)            as bytes
                   ,  'Temporary'           as tstype
                from  dba_temp_files
               group  by tablespace_name, 'Temp-TblSpc'
              union
              select  tablespace_name       as tblspc
                   ,  sum(bytes)            as bytes
                   ,  'Regular'             as tstype
                from  dba_data_files
               where  tablespace_name in ( select distinct temporary_tablespace from dba_users )
               group  by tablespace_name, 'Reg-TblSpc'
            )  f
            left join
            v$sort_usage  s  on ( f.tblspc = s.tablespace )
            join
            ( select  value
                from  v$parameter
               where  name = 'db_block_size'
            )  b  on (1=1)
    group  by f.tblspc
             , f.tstype
             , f.bytes
    order  by 1 ;And here's what I use to look at which users are using temp-space:
    select  t.tablespace
         ,  t.username
         ,  f.tstype  as type
         ,  round((sum(decode(segtype, 'SORT',     t.blocks,0))*b.bsz)/1024/1024,2)  as sort_mb
         ,  round((sum(decode(segtype, 'DATA',     t.blocks,0))*b.bsz)/1024/1024,2)  as data_mb
         ,  round((sum(decode(segtype, 'HASH',     t.blocks,0))*b.bsz)/1024/1024,2)  as hash_mb
         ,  round((sum(decode(segtype, 'INDEX',    t.blocks,0))*b.bsz)/1024/1024,2)  as indx_mb
         ,  round((sum(decode(segtype, 'LOB_DATA', t.blocks,0))*b.bsz)/1024/1024,2)  as lobs_mb
         ,  round((sum(decode(segtype, 'SORT', 0, 'DATA', 0, 'HASH', 0, 'INDEX', 0, 'LOB_DATA', 0
                                                 , t.blocks  ))*b.bsz)/1024/1024,2)  as othr_mb
         ,  round((sum(t.blocks)*b.bsz)/1024/1024,2)                                 as all_mb
         ,  round((max(u.blks)*b.bsz)/max(f.bytes)*100,2)   as "All-TS-%"
         ,  round((max(u.blks)*b.bsz)/1024/1024) ||'/'||
            round(max(f.bytes)/1024/1024,2)  as "All-TS-Usage-mb"
      from  v$tempseg_usage  t 
            cross join
            ( select value as bsz from v$parameter where name = 'db_block_size' )  b 
            left join 
            ( select  tablespace_name       as tablespace
                   ,  sum(bytes)            as bytes
                   ,  'Temporary'           as tstype
                from  dba_temp_files
               group  by tablespace_name
            union
              select  tablespace_name 
                   ,  sum(bytes)       
                   ,  'Regular'         
                from  dba_data_files
               where  tablespace_name in
                        ( select distinct temporary_tablespace from dba_users )
               group  by tablespace_name
            )  f  on ( t.tablespace = f.tablespace )
            left join
            ( select  tablespace, sum(blocks) as blks
                from  v$tempseg_usage
               group  by tablespace
            ) u  on ( t.tablespace = u.tablespace )
    group  by  t.username, t.tablespace, f.tstype, b.bsz
    order  by  t.tablespace, t.username ;Maybe that helps.

  • A lot of messages "direct path write temp" and "direct path read temp"

    Hello, all
    Please, understand me, what is going on in my system (DB: Oracle database 11.2.0.3, OS: Windows 2008 R2).
    In AWR report (1 hour) I see next:
    Foreground Wait Events
                                                                 Avg               
                                            %Time Total Wait    wait    Waits   % DB
    Event                             Waits -outs   Time (s)    (ms)     /txn   time
    direct path write temp          132,627     0      1,056       8      0.8   21.7
    direct path read temp           308,969     0        565       2      2.0   11.6
    log file sync                    19,228     0        241      13      0.1    5.0
    direct path write                17,698     0        135       8      0.1    2.8
    db file sequential read          21,149     0         94       4      0.1    1.9
    SQL*Net message from dblin           59     0          5      86      0.0     .1
    Segments by Direct Physical Reads         DB/Inst: SGRE/sgre  Snaps: 1039-1040
    -> Total Direct Physical Reads:         392,273
    -> Captured Segments account for   94.7% of Total
               Tablespace                      Subobject  Obj.        Direct       
    Owner         Name    Object Name            Name     Type         Reads  %Total
    ** MISSING TEMP       ** TRANSIENT: 437734 MISSING ** UNDEF       38,290    9.76
    DBSNMP     TEMP       MGMT_TEMPT_SQL                  TABLE       38,242    9.75
    ** MISSING TEMP       ** TRANSIENT: 438784 MISSING ** UNDEF       37,790    9.63
    ** MISSING TEMP       ** TRANSIENT: 437312 MISSING ** UNDEF       37,661    9.60
    ** MISSING TEMP       ** TRANSIENT: 439257 MISSING ** UNDEF       37,477    9.55Some selects:
    SELECT   S.sid,
             T.blocks * TBS.block_size / 1024 / 1024 mb_used, T.tablespace, T.SEGTYPE
    FROM     v$sort_usage T, v$session S, v$sqlarea Q, dba_tablespaces TBS
    WHERE    T.session_addr = S.saddr
    AND      T.sqladdr = Q.address (+)
    AND      T.tablespace = TBS.tablespace_name
    AND      S.sid = 732
    ORDER BY S.username, S.sid;
    SID     MB_USED     TABLESPACE     SEGTYPE
    732     2          TEMP          LOB_DATA
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          INDEX
    732     1          TEMP          DATA
    732     1          TEMP          INDEX
    732     1          TEMP          LOB_INDEX
    select st.sid, sn.name, st.VALUE
    from V$statname sn, v$sesstat st
    where st.STATISTIC# = sn.STATISTIC#
    and (sn.name like 'sorts%')
    and st.sid in (select sid from v$session_wait where event like '%direct path write temp%')
    order by st.sid
    SID     NAME          VALUE
    732     sorts (memory)     591408
    732     sorts (rows)     102126
    732     sorts (disk)     0Why I do not see any disk sorts? If TEMP is used for no sort operations, then for which operations?
    How I can see that? How can I decrease direct path write temp without tuning SQL?
    Additional information:
    PGA_AGGREGATE_TARGET is set to big value - 6GB (3GB enough due to advisory recommendation)
    Please, help.
    Regards, user12103911.

    user12103911 wrote:
    SELECT optimal_count, round(optimal_count*100/total, 2) optimal_perc,
    onepass_count, round(onepass_count*100/total, 2) onepass_perc,
    multipass_count, round(multipass_count*100/total, 2) multipass_perc
    FROM
    (SELECT decode(sum(total_executions), 0, 1, sum(total_executions)) total,
    sum(OPTIMAL_EXECUTIONS) optimal_count,
    sum(ONEPASS_EXECUTIONS) onepass_count,
    sum(MULTIPASSES_EXECUTIONS) multipass_count
    FROM   v$sql_workarea_histogram); 
    OPTIMAL_COUNT OPTIMAL_PERC  ONEPASS_COUNT ONEPASS_PERC  MULTIPASS_COUNT MULTIPASS_PERC
    13150685      100           0             0             0               0No n-pass executions.That's a pretty convincing display - given that your AWR manages to NAME an object that is in the TEMP tablespace, an obvious point to follow up is global temporary tables. If you have any declared as "on commit preserve" (duration = 'SYS$SESSION') then you could have code which does "insert /*+ append */ into gtt", and if you then query this in parallel (or - since you're on 11.2.0.3 - the data volume is large enough) Oracle could choose to do direct path writes to load the GTT and direct path reads to read it back.
    Regards
    Jonathan Lewis

  • Shrinking a Locally Managed Temporary Tablespace

    So, even thoguh the documentation is pretty clear about how to use this feature, I cannot get it to do what I expect it to do for me.
    And that would be shrinking the tempfile ;)
    Now lets face it, I have a large tempfile and want to resize it without restarting the database:
    C:\Users\Administrator>sqlplus / as sysdba
    SQL*Plus: Release 11.2.0.2.0 Production on Di Nov 20 05:49:59 2012
    Copyright (c) 1982, 2010, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
    SQL> select file_name
    , ceil(bytes / 1024 / 1024) "size MB"
    from dba_temp_files
    FILE_NAME size MB
    R:\MXVC01\TEMP01.DBF 31,231
    SQL> select su.username
    , ses.sid
    , ses.serial#
    , su.tablespace
    , ceil((su.blocks * dt.block_size) / 1048576) MB
    from v$sort_usage su
    , dba_tablespaces dt
    , v$session ses
    where su.tablespace = dt.tablespace_name
    and su.session_addr = ses.saddr
    USERNAME SID SERIAL# TABLESPACE MB
    VPXADMIN 15 15 TEMP 14
    VPXADMIN 17 5 TEMP 1,203
    VPXADMIN 17 5 TEMP 1
    VPXADMIN 18 3 TEMP 7
    VPXADMIN 19 3 TEMP 1
    VPXADMIN 144 3 TEMP 1
    VUMADMIN 156 2597 TEMP 1
    7 rows selected.
    Or this one:
    SQL> select tablespace_size/1024/1024 "tablespace_size mb"
    , allocated_space/1024/1024 "allocated_space mb"
    , free_space/1024/1024 "free_space mb"
    from dba_temp_free_space
    tablespace_size mb allocated_space mb free_space mb
    31230,9922 1228,99219 30002
    Documetation from here: http://docs.oracle.com/cd/E11882_01/server.112/e25494/tspaces007.htm#ADMIN12353
    +"Shrinking a Locally Managed Temporary Tablespace+
    +Large sort operations performed by the database may result in a temporary tablespace growing and occupying a considerable amount of disk space. After the sort operation completes, the extra space is not released; it is just marked as free and available for reuse. Therefore, a single large sort operation might result in a large amount of allocated temporary space that remains unused after the sort operation is complete. For this reason, the database enables you to shrink locally managed temporary tablespaces and release unused space.+
    +You use the SHRINK SPACE clause of the ALTER TABLESPACE statement to shrink a temporary tablespace, or the SHRINK TEMPFILE clause of the ALTER TABLESPACE statement to shrink a specific tempfile of a temporary tablespace. Shrinking frees as much space as possible while maintaining the other attributes of the tablespace or tempfile. The optional KEEP clause defines a minimum size for the tablespace or tempfile.+
    +Shrinking is an online operation, which means that user sessions can continue to allocate sort extents if needed, and already-running queries are not affected.+
    +The following example shrinks the locally managed temporary tablespace lmtmp1 to a size of 20M.+
    +ALTER TABLESPACE lmtemp1 SHRINK SPACE KEEP 20M;+
    +The following example shrinks the tempfile lmtemp02.dbf of the locally managed temporary tablespace lmtmp2. Because the KEEP clause is omitted, the database attempts to shrink the tempfile to the minimum possible size.+
    +ALTER TABLESPACE lmtemp2 SHRINK TEMPFILE '/u02/oracle/data/lmtemp02.dbf';"+
    OK, lets do it:
    SQL> alter tablespace temp shrink tempfile 'R:\MXVC01\TEMP01.DBF';
    alter tablespace temp shrink tempfile 'R:\MXVC01\TEMP01.DBF'
    ERROR at line 1:
    ORA-03214: File Size specified is smaller than minimum required
    It seems there is a bug? Should I report it, or is it the expected behaviour?
    Now lets try this one:
    SQL> alter tablespace temp shrink tempfile 'R:\MXVC01\TEMP01.DBF' keep 2048M;
    Tablespace altered.
    SQL> select file_name
    , ceil(bytes / 1024 / 1024) "size MB"
    from dba_temp_files
    FILE_NAME size MB
    R:\MXVC01\TEMP01.DBF 31,231
    So .... this lasts about *10 minutes*, and nothing changes?
    It seems there is a bug? Should I report it, or is it the expected behaviour?
    Could someone enlighten me, what this SHRINK is actually doing?
    Is it worth to report this as bug, if not a software bug it is at least a documentation bug because it doesn't mention under which conditions it is working?
    P.S.: OMG the posting looks terrible, who's the one to blame for this forum software where it is not possible to use fixed size fonts, or format paragraphs as code, or what about the fact that the forum software is using default SQLPlus output as META for some graphical lines?
    Isn't this the forum for Oracle Database users?
    Edited by: Gerrit Haase on 20.11.2012 13:44

    So, you are kidding with me? No? Who are you?
    How can I block users here? Is there a moderator present at this forum?
    Maybe you read my initial post again?
    I didn't look at the wrong place.
    I reported you for general abuse.
    SQL> define
    DEFINE _DATE           = "20.11.12" (CHAR)
    DEFINE CONNECTIDENTIFIER = "MXVC01" (CHAR)
    DEFINE _USER           = "SYS" (CHAR)
    DEFINE _PRIVILEGE      = "AS SYSDBA" (CHAR)
    DEFINE SQLPLUSRELEASE = "1102000200" (CHAR)
    DEFINE _EDITOR         = "Notepad" (CHAR)
    DEFINE OVERSION = "Oracle Database 11g Release 11.2.0.2.0 - 64bit Production" (CHAR)
    DEFINE ORELEASE = "1102000200" (CHAR)
    SQL> SELECT * FROM dba_temp_free_space;
    TABLESPACE_NAME TABLESPACE_SIZE ALLOCATED_SPACE FREE_SPACE
    TEMP 3,2748E+10 1306517504 3,1443E+10
    SQL> select TABLESPACE_SIZE/power(2,20), ALLOCATED_SPACE/power(2,20), FREE_SPACE/power(2,20) from dba_temp_free_space ;
    TABLESPACE_SIZE/POWER(2,20) ALLOCATED_SPACE/POWER(2,20) FREE_SPACE/POWER(2,20)
    31230,9922 1245,99219 29986
    SQL> ALTER TABLESPACE temp SHRINK SPACE;
    Tablespace altered.
    SQL> select TABLESPACE_SIZE/power(2,20), ALLOCATED_SPACE/power(2,20), FREE_SPACE/power(2,20) from dba_temp_free_space ;
    TABLESPACE_SIZE/POWER(2,20) ALLOCATED_SPACE/POWER(2,20) FREE_SPACE/POWER(2,20)
    31230,9922 1244,99219 *29986*
    R:\mxvc01>dir temp
    Volume in drive R is Disk_R
    Volume Serial Number is 248B-61D4
    Directory of R:\mxvc01
    20.11.2012 08:09 32.748.077.056 TEMP01.DBF
    1 File(s) 32.748.077.056 bytes
    0 Dir(s) 8.259.297.280 bytes free
    SQL> alter tablespace temp shrink tempfile 'R:\mxvc01\TEMP01.DBF';
    alter tablespace temp shrink tempfile 'R:\mxvc01\TEMP01.DBF'
    ERROR at line 1:
    ORA-03214: File Size specified is smaller than minimum required
    *It clearly says that there is 29986 MB Space FREE and the above shrink space changes nothing and so does shrink tempfile:*
    SQL> alter tablespace temp shrink tempfile 'R:\mxvc01\TEMP01.DBF';
    alter tablespace temp shrink tempfile 'R:\mxvc01\TEMP01.DBF'
    ERROR at line 1:
    ORA-03214: File Size specified is smaller than minimum required
    SQL> alter tablespace temp shrink tempfile 'R:\mxvc01\TEMP01.DBF' KEEP 20M;
    Tablespace altered.
    R:\mxvc01>dir temp
    Volume in drive R is Disk_R
    Volume Serial Number is 248B-61D4
    Directory of R:\mxvc01
    20.11.2012 08:24 32.748.077.056 TEMP01.DBF
    1 File(s) 32.748.077.056 bytes
    0 Dir(s) 8.259.280.896 bytes free
    *... nothing changes, the tempfile isn't smaller now ...*

  • Refresh Materialized views

    Hi,
    While I was refresh the materialized view I found below error.
    SQL> exec dbms_mview.refresh(MV1','C');
    BEGIN dbms_mview.refresh('MV1','C'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-01652: unable to extend temp segment by 1280 in tablespace TEMP
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2251
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2457
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2426
    ORA-06512: at line 1
    I increased 3 gb, again got the smw error
    and the 11gb TEMP tablespace size was full.
    So please advise How to resolve this issue?
    Thank,
    Praveen

    Hello,
    You should check your Temporary Tablespace so as to be sure of which statement is consumming so much
    space. The following query may help you:
    SELECT S.sid || ',' || S.serial# sid_serial, S.username, Q.hash_value, Q.sql_text,
    T.blocks * TBS.block_size / 1024 / 1024 "Mo used", T.tablespace
    FROM v$sort_usage T, v$session S, v$sqlarea Q, dba_tablespaces TBS
    WHERE T.session_addr = S.saddr
    AND T.sqladdr = Q.address
    AND T.tablespace = TBS.tablespace_name
    ORDER BY S.sid;On the other hand, is this refresh worked before or is it a new MV to refresh ?
    Which option did you use to create this MV ?
    Best regards,
    Jean-Valentin

Maybe you are looking for

  • Can't see Time Capsule disk

    Hi there, need some help. I can no longer see my Time Capusle disk (and it's not performing back ups). I've just moved and set my time capsule back up as my wireless router last night. All seemed to be working fine. Came home from work today and coul

  • Delete photo clip in imovie?

    I have an imovie full of photos only....my song is too short...how do I delete the photos to match the song....thanks!!! i don't want to go all the way back to iphoto and re-import them.

  • Anyone knows what these messages mean ???

    when i do a build-format in DVDSP i get these messages in the log : Warning: The file 'VIDEOGRAPHE_2006.layout' found in the VIDEO_TS or HVDVD_TS folder will not be included in the final disc. Warning: The file 'VOB_DATA.LAY' found in the VIDEO_TS or

  • How can i get a new motherboard?

    I have an iMac and it doesn't work! My technical advisor said, it needs a new motherboard. Anyone who knows how can I get one from Apple Store? (I couldn't see this option on the website)

  • Create user in SAP GRC AC 5.3 for each module (RAR, CUP, SPM, ERM).

    Hello, I have a doubt. The users of the modules of the SAP GRC AC 5.3 have to created in the UME of the EP Core, is that right?? And thet add the roles of each user for each module (RAR, CUP, SPM, ERM), is that right? Best Regards. Pablo Mortera.