SQLs (completed & currently running ) in a session

Is there a query which will give me the list of SQLs that have run & currently running since the start of a session ? I also need to know the start and end times (or) the time taken for each of the SQLs.

I want an output similar to the following query in DB2,
===============================
Here is an example query that shows you any statements that have been executing for more than one minute along with the authid, the status of the application and the first few characters of the statement text.
SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID, AGENT_ID,       APPL_STATUS,SUBSTR(STMT_TEXT,1,20) AS SQL_TEXT  FROM SYSIBMADM.LONG_RUNNING_SQL WHERE ELAPSED_TIME_MIN > 0 ORDER BY ELAPSED_TIME_MIN DESC
here are the results for this example
ELAPSED_TIME_MIN AUTH_ID  AGENT_ID APPL_STATUS  SQL_TEXT
6                EATON         878 LOCKWAIT     update org set deptnHere you can see that an application has been running for 6 minutes and is currently waiting on a lock.
================================
Message was edited by:
user604968
Message was edited by:
user604968
Message was edited by:
user604968

Similar Messages

  • Explain plan for SQL running in a session

    Hi. Can you get the explain plan information for sql that's currently running in a session? I know I can use the session report to see the active SQL, but I don't know if it's possible to get the explain plan information from there, like you can with TOAD's session manager.

    I've put together a query for the v$sql_plan in 9iR2.
    Depending on what you use, you can probably drop some columns (eg OTHER and partition columns) and you could drive it from the v$session by getting the hash_value from there for the sid you are interested in :
    (select * from v$sql_plan where hash_value =
    (select sql_hash_value from v$session where sid=:sid))
    select level, optimizer, lpad('_',1*(level-1),'_')||operation operation,
    options, object_owner||'.'||object_name obj_name, search_columns,
    ltrim(to_char(cardinality,'999,999,999')) no_rows,
    ltrim(to_char(bytes/1024,'999,999')) kbytes, cost tot_cost,
    object_node link, id, parent_id, other_tag||':'||other other,
    partition_start, partition_stop, cpu_cost, io_cost,
    access_predicates, filter_predicates,
    round(temp_space/(1024*1024),2) temp_space_mb
    from (select * from v$sql_plan where hash_value = :hash_val)
    start with id=0
    connect by prior id = parent_id and prior child_number = child_number
    order by child_number, id, position;

  • Current running SQL stms execution plan?

    Hi,
    Is it any ways to findout the current running SQL stms execution plan?
    without using Explain plan & autotrace.
    Thanks in advance,
    Thomas.

    I'm using this code. You just have to give the Session Identifier (&SID ):SELECT     '| Operation                                     |  Objet   | Lignes| Bytes|  Cout  | Pstart| Pstop |' as "Plan Table"  FROM DUAL
    UNION ALL
    SELECT     '----------------------------------------------------------------------------------------------------' FROM DUAL
    UNION ALL
    SELECT * FROM
             (SELECT /*+ NO_MERGE */
              RPAD('| '||
                   SUBSTR(
                        LPAD(' ',1*(LEVEL-1)) || OPERATION || DECODE(OPTIONS, NULL,'',' '||OPTIONS), 1, 47
                         ), 48, ' '
              )||'|'||
              RPAD(
                   SUBSTR(OBJECT_NAME||' ',1, 9), 10, ' '
              )||'|'||
              LPAD(
                   DECODE(CARDINALITY,
                        NULL,'  ',
                        DECODE(SIGN(CARDINALITY-1000),
                              -1, CARDINALITY||' ',
                             DECODE(SIGN(CARDINALITY-1000000),
                                   -1,TRUNC(CARDINALITY/1000)||'K',
                                  DECODE(SIGN(CARDINALITY-1000000000),
                                       -1,TRUNC(CARDINALITY/1000000)||'M',
                                       TRUNC(CARDINALITY/1000000000)||'G')
                        ), 7, ' '
              )||'|'||
              LPAD(
                   DECODE(BYTES,
                        NULL,' ',
                        DECODE(SIGN(BYTES-1024),
                             -1, BYTES||' ',
                             DECODE(SIGN(BYTES-1048576),
                                  -1, TRUNC(BYTES/1024)||'K',
                                  DECODE(SIGN(BYTES-1073741824),
                                       -1,TRUNC(BYTES/1048576)||'M',
                                       TRUNC(BYTES/1073741824)||'G')
                        ), 6, ' '
              )||'|'||
              LPAD(
                   DECODE(COST,
                        NULL,' ',
                        DECODE(SIGN(COST-10000000),
                             -1, COST||' ',
                             DECODE(SIGN(COST-1000000000),
                                  -1, TRUNC(COST/1000000)||'M',
                                  TRUNC(COST/1000000000)||'G')
                        ), 8, ' '
              )||'|'||
              LPAD(
                   DECODE(PARTITION_START,
                        'ROW LOCATION', 'ROWID',
                        DECODE(PARTITION_START,
                             'KEY', 'KEY',
                             DECODE(PARTITION_START,
                                  'KEY(INLIST)', 'KEY(I)',
                                  DECODE(SUBSTR(PARTITION_START, 1, 6),
                                       'NUMBER', SUBSTR(SUBSTR(PARTITION_START, 8, 10), 1,LENGTH(SUBSTR(PARTITION_START, 8, 10))-1),
                                       DECODE(PARTITION_START,
                                            NULL,' ',
                                            PARTITION_START)
                        )||' ', 7, ' '
              )||'|'||
              LPAD(
                   DECODE(PARTITION_STOP,
                        'ROW LOCATION', 'ROW L',
                        DECODE(PARTITION_STOP,
                             'KEY', 'KEY',
                             DECODE(PARTITION_STOP,
                                  'KEY(INLIST)', 'KEY(I)',
                                  DECODE(SUBSTR(PARTITION_STOP, 1, 6),
                                  'NUMBER', SUBSTR(SUBSTR(PARTITION_STOP, 8, 10), 1,LENGTH(SUBSTR(PARTITION_STOP, 8, 10))-1),
                                  DECODE(PARTITION_STOP,
                                       NULL,' ',
                                       PARTITION_STOP)
                   )||' ', 7, ' '
              )||'|' AS "Explain plan"
         FROM V$SQL_PLAN
         START WITH (ADDRESS = (SELECT SQL_ADDRESS FROM V$SESSION WHERE SID=&SID)
                   AND HASH_VALUE = (SELECT SQL_HASH_VALUE FROM V$SESSION WHERE SID=&SID)
                   AND CHILD_NUMBER = 0
                   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)
    UNION ALL
    SELECT '----------------------------------------------------------------------------------------------------' FROM DUAL;Regards,
    Yoann.

  • What SQL Server Agent jobs are currently running and for how long

    Is there a way to tell what SQL Server Agent jobs are currently running and for how long?  View history isn't working in my case because it's only showing completed jobs.  John Schroeder

     You can use the "Job Activity Monitor" for doing this.  Do the following steps. It will open up the Job Activity Monitor.
    1.    In Object Explorer, connect to an instance of the SQL Server Database Engine, and then expand that instance.
    2.    Expand SQL Server Agent.
    3.    Right-click Job Activity Monitor and click View Job Activity.
    4.    In the Job Activity Monitor, you can view details about each job that is defined for this server.
    In Job Activity Monitor page, we have column called Status. It will indicate whether job is executing or idle. Last Run column will give you the last invocation time of this job.
    Use the following link for further reference.
    http://msdn.microsoft.com/en-us/library/ms187449.aspx
    Thanks,
    Sateesh.
    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

  • Can generate the TKPROF file without the SQL is not running completed ?

    Dear all:
    I want to generate the TKPROF file from the trace file, Can generate the TKPROF file without the SQL is not running completed ? Is it the TKPROF file can be used? because the report is too large. My environment is ORACLE 11.5.9
    Regards
    Terry

    When you can wait for completion, then that's the easiest route.
    When you can't wait, you'll have to use a different method. I suggest to watch the v$ views for what your session is doing. Views like v$session, v$session_wait, v$sess_io and the views starting with v$sql. Also worth mentioning is Tanel Poder's site, which contains some very useful scripts for diagnosing performance problems this way: http://tech.e2sn.com/.
    Regards,
    Rob.

  • I have a MAC Pro from 2011 currently running MAC OS 10.9.5.  This weekend I cloned the MAC HD drive to a new SSD drive for improved performance.  The clone was completed successfully with no errors.  After the clone completed I successfull restarted my sy

    I have a MAC Pro from 2011 currently running MAC OS 10.9.5.  This weekend I cloned the MAC HD drive to a new SSD drive for improved performance.  The clone was completed successfully with no errors.  After the clone completed I successfully restarted my system using the SSD as the boot device.  I then successfully tested all of my products, including Photoshop CS6 and all of its plug-ins.  I successfully tested the key features that I frequently use.  Today while attempting to launch Photoshop CS6 a message is being displayed indicating that a scratch disk cannot be found.  All drives are available on the system via the Finder and Disk Utility.  I can access all drives including the old MAC HD which is no longer the boot device.  I've even attempted to launch Photoshop from the old device yet the same error persist.  Is there a way to review/edit/change Photoshop preferences if Photoshop doesn't launch?  I've even restarted my system several times to see if that would resolve the issues.  Does anyone have any recommendations for this issue?  Have you previously address this issue? 
    Thank you Gregg Williams

    Boilerplate text:
    Reset Preferences
    http://forums.adobe.com/thread/375776
    1) Close the program and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (not reversible)
    or
    2) Move the Folder. See:
    http://www.bugge.com/Family-and-friends/Illy/illy.html
    --OB

  • How do i start an Oracle Trace?   For a currently running session?

    How do i start an Oracle Trace? For a currently running session? How do i read it?

    How do i read it? Ohh forgot this one. That tracing will create a tracefile in udump directory and you need to run tkprof to parse that trace file so that you can read it. To find the udump dir type "show parameter user_dump_dest" at sqlplus prompt and then run tkprof like (from OS prompt):
    tkprof file_name.trc file_name.txt sys=no
    Type only tkprof for more option of this tool.
    Daljit Singh

  • I'm currently running 10.6.8 and would like to upgrade to mountain lion but all i keep getting is the following: We could not complete your purchase. OS X Mountain Lion is not compatible with this computer. help

    I'm currently running 10.6.8 and would like to upgrade to mountain lion but all i keep getting is the following: We could not complete your purchase. OS X Mountain Lion is not compatible with this computer. help

    ERA AND MCM wrote:
    We could not complete your purchase. OS X Mountain Lion is not compatible with this computer.
    it means exactly that, you mac is not compatible to run ML. http://support.apple.com/kb/SP654

  • I want to sell my MBP. How do I completely erase my 2007, 17-inch Macbook Pro that is currently running Snow Leopard. I DO NOT HAVE THE ORIGINAL DISK THAT CAME WITH THE BOX ANYMORE.

    I want to sell off my old MacBook Pro and do not want any of my old stuff on it for the next person to fool around with. I'd like a clean-slate for the next guy/gal. It's a 17-inch that I purchased back in '07. It is currently running Snow Leopard after I installed it myself about two years ago. I DO NOT HAVE THE ORIGINAL DISK THAT CAME WITH THE LAPTOP IN THE BOX.

    raeusebio32 wrote:
    I DO NOT HAVE THE ORIGINAL DISK THAT CAME WITH THE LAPTOP IN THE BOX.
    No problem, stick in your 10.6.3 Snow Leopard retail disk you used to upgrade from 10.4/10.5 with
    If you don't have this disk anymore, you can order one online at Apple.com for $29, they don't sell it in the physical stores.
    http://store.apple.com/us/product/MC573Z/A
    Reboot holding the c or option key down to boot from the disk, select Disk Utility from under the Utilities menu on the second screen (first is language selection)
    Now select your boot drive on the left with the drive makers name and disk size and click Erase > Security Option > Zero All Data and click Erase
    It will take some time to complete as it's making sure all your personal data if not easily recoverable off the drive using software.
    Now quit and you will be back in the installer window, install 10.6 and it will reboot to the "Welcome Video" you can choose to press the power button down and do a hard shutdown, the computer will boot again to this video for the next owner.
    If you need even more security in your data deletion efforts I suggest you read this
    How do I securely delete data from the machine?

  • Current running sql statement in procedure?

    How to identify the current running sql statement in procedure or package? From the v$sqlarea, i can see the only procedure name with parameters, but not current execution statement? is there any dba view to know the current execution statement in 9i & 10g ?

    hi
    u can also use dba_source view to know which sql statement issued by which user

  • How to detect sessions that are currently running parallel queries?

    Hi everyone,
    How to detect session that are currently running parallel queries?
    - The only way i can think of is querying pdml_Status from gv$session?
    - Is there a better way to do this?
    Follow up question:
    After detecting sessions that are running parallel queries how do i identify which sessions are slaves of which session?
    thanks!

    Start with V$PX_SESSION, however also take a look at V$PQ_* and V$PX_* tables.

  • Find the current sql which is running against database

    Hi,
    How to find out the current sql which is running against database?

    Hi,
    You can use V$SESSION_LONG_OPS and V$SQL to get the long running(6 seconds or above) queries. You need to join these two views to get the SQL text.
    V$SESSION_LONGOPS : Will give you the long running SQL ID.
    V$SQL : Will give you the text of query against the SQL ID.
    Refere the below link for more details:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2092.htm#REFRN30227
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2113.htm#REFRN30246
    Cheers,

  • How to know currently running ddl  by dba_views in oracle 9i

    sql_hash_value in v$session is showing 0 .presently create table is running which is done by copying from another table.
    Edited by: apusumit on May 16, 2012 1:46 AM
    Edited by: apusumit on May 17, 2012 12:08 AM

    apusumit wrote:
    sql_hash_value in v$session is showing 0 .presently create table is running
    Edited by: apusumit on May 16, 2012 1:46 AMSQL_HASH_VALUE 0 means sql has been completed. If you are sure that it is still running and showing SQL_HASH_VALUE 0, then show us what are you doing and how Oracle is responding you by simply copy and paste SQLplus screen text by below commands :
    set linesize 200
    set pagesize 1000
    select sql_text from v$sql where (ADDRESS,HASH_VALUE) in (select sql_address,sql_hash_value from v$session where sid= &sid_number);
    Anand @ find the current sql which is running against database
    OR
    select c.spid b1, b.osuser c1, b.username c2, b.sid b2, b.serial# b3,
    a.sql_text
    from v$sqltext a, v$session b, v$process c
    where a.address = b.sql_address
    -- and b.status = 'ACTIVE' /* YOU CAN CHOOSE THIS OPTION ONLY TO SEE
    -- ACTVE TRANSACTION ON THAT MOMENT */
    and b.paddr = c.addr
    and a.hash_value = b.sql_hash_value
    order by c.spid,a.hash_value,a.piece
    Adith @ What are current query running
    You can too check LAST_DDL_TIME of user_objects view.
    Regards
    Girish Sharma

  • How to Get Current running Sqltext in 10g

    I'm using 10g and i'm using following query to get current running sql.
    SELECT A.SID,B.HASH_VALUE, OSUSER, USERNAME, SQL_TEXT
    FROM V$SESSION A, V$SQLTEXT B
    WHERE B.HASH_VALUE = A.SQL_HASH_VALUE
    AND USERNAME LIKE upper('%UOBA%')
    ORDER BY B.HASH_VALUE, B.PIECE;
    This does work for all user-triggered sqls,procedures etc.
    But when i submit a Oracle Job the above qurey doesn't give any output.So,could please anybody help me in this regard.
    Thanks in Advance.

    I have found a way to retrieve some SQL statements for a session started by DBMS_JOB using v$open_cursor: however in my test, you can only retrieve some SQL statements in v$sql_area but not all of them: query takes some time to execute and some committed statements are not (or nor more) in v$open_cursor:
    select s.sid, s.serial#, s.username, sq.sql_text
    from v$open_cursor oc, v$sqlarea sq, v$session s
    where s.username = 'TEST'
    and oc.saddr = s.saddr
    -- only for session started by DBMS_JOB
    and s.sql_hash_value = 0
    and oc.address = sq.address
    and oc.hash_value = sq.hash_value;Message was edited by:
    Pierre Forstmann

  • ADS : FP_TEST_00 Exception getting currently running XMLForm Module version

    Hi,
    We have installed ADS and Currently configuring it.
    The Reports FP_PDF_TEST_00 is working fine. But the reports FP_TEST_00 is hanging when i specify the Printer name and click on Print preview.
    The Following error message i got in the default trace file.
    1.5#001560DE2A38007F000000060000249E00044F4DBB40B6FF#1213095188495#com.adobe.AdobeDocumentServices#com.adobe/AdobeDocumentSer
    vices#com.adobe.AdobeDocumentServices#ADSUSER#136##lux09208_D10_13839050#Guest#6959e66036db11ddc504001560de2a38#SAPEngine_Appl
    ication_Thread[impl:3]_52##0#0#Error##Plain###Exception getting currently running XMLForm Module version.
    java.lang.IllegalStateException: No transaction
            at com.adobe.service.J2EEConnectionFactoryManagerPeerImpl.getConnection(J2EEConnectionFactoryManagerPeerImpl.java:70)
            at com.adobe.ads.proxy.ServiceLocator.getXmlfmFactory(Unknown Source)
            at com.adobe.EJB_XMLFormAgent.getFactory(Unknown Source)
            at com.adobe.EJB_XMLFormAgent.getVersion(Unknown Source)
            at com.adobe.AdobeDocumentServicesEJB.checkXmlfmVersion(Unknown Source)
            at com.adobe.AdobeDocumentServicesEJB.ejbCreate(Unknown Source)
            at sun.reflect.GeneratedMethodAccessor265.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at com.sap.engine.services.ejb.session.stateless_sp5.BeanFactory.createObject(BeanFactory.java:113)
            at com.sap.engine.services.ejb.util.pool.ContainerPoolImpl.doResizeOneStepUp(ContainerPoolImpl.java:374)
            at com.sap.engine.services.ejb.util.pool.ContainerPoolImpl.ensureNotEmpty(ContainerPoolImpl.java:343)
            at com.sap.engine.services.ejb.util.pool.ContainerPoolImpl.pop(ContainerPoolImpl.java:291)
            at com.sap.engine.services.ejb.session.stateless_sp5.BeanFactory.getActiveBean(BeanFactory.java:188)
            at com.sap.engine.services.ejb.session.stateless_sp5.StatelessContainerFP.getActiveBean(StatelessContainerFP.java:183)
            at com.adobe.AdobeDocumentServicesLocalLocalObjectImpl0.rpData(AdobeDocumentServicesLocalLocalObjectImpl0.java:87)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java
    :126)
            at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
            at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
            at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
            at SoapServlet.doPost(SoapServlet.java:51)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    Also the FP_CHECK_DESTINATION_SERVICE report is also hanging with out any output.
    The RFC Connectivity ADS is working properly, The Users ADSUSEr and ADS_AGENt are configured properly. I am also able the test the Destination FP_ICF_DATA_<SID> in Visual Admin properly.
    The AdobeDocumentSErvices portal is also displaying the version number for me.
    Please let me know how this issue can be sorted out.

    Hello Subramanian,
    I am not sure if you have solved the problem of FP_CHECK_DESTINATION_SERVICE report. Using this report test you can check if the complete configuration of the destination service and the ICF service is correct. Since this report is not getting results in your case, I suspect there is problem in Destination Service or the ICF Service.
    Kindly do all the steps mentioned here.
    http://help.sap.com/saphelp_nw70/helpdata/en/44/63eefb818c311ee10000000a155369/content.htm
    Regards,
    Shubham

Maybe you are looking for

  • Accounts on 2 computers

    I have 2 computers with separate accounts for email (primary and sub account). Verizon FIOS made recent changes with email.  Now my emails have jumped to the other computer with the sub-account. How do I get me emails back on my computer in my primar

  • How to enable background color printing?

    how to enable background color printing?

  • Hard drive too small to hold all my music

    I have an iBook that I got from my aunt for graduation that I am using to load music into my new iPod. Unfortunately there is only a 9 gig hard drive on the computer, so i cannot keep all my music files on it. Is there any way to avoid having all the

  • Itunes encountered errors

    How do I install iTunes for 64-bit.  It encounters errors whenever I try.

  • Oracle gateway for MS sql server 2005

    Is Oracle 9i Gateway for MS SQL Server compatible with SQL 2005? If not what are the other options?