iPhone App

    Handy Commands

     DBMS_XPLAN.DISPLAY function to display the execution plan.

    SET LINESIZE 300 PAGESIZE 300
    SELECT * FROM   TABLE(DBMS_XPLAN.DISPLAY);

    /*+ gather_plan_statistics */

    select /*+ gather_plan_statistics */ ........

    then    select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));



    Sql Advisor Privileges

    grant advisor to &username;
     grant administer sql tuning set to &username;
    grant select any dictionary to &username;

    Locks

    set numwidth 12
    set lines 255 pages 300
    column event format a12 tru
    select  sess.username,l.sid,sess.serial#, l.addr, l.type, l.id1, l.id2, decode(l.block,0,'blocked',1,'blocking',2,'global') block, sw.event, sw.seconds_in_wait sec
    from
    v$lock l, v$session_wait sw,v$session sess
    where
    (l.sid = sw.sid )
    and l.sid=sess.sid and
    l.block in (0,1)
    order by sess.username,l.type,  l.sid;


    Kill Users

    select 'alter system kill session '''||sid||','||serial#||''''||' immediate;'
    from v$session
    where type='USER' and username='&username'
    /