How to Get TOP Sql

Hi All,
I need to get TOP sql query in 11g Database.
I dont know about PT.
User will carry on some testing activity on the Database, i need to get the top sql from the database.
There is no access to AWR, ADDM and Entriprise console.
I need to get the output of the queries by executing some sql.
Can some body help me in this regards.
Thanking You
Pramodh

>
Whether it is possible to get the full set of sql, i tried executing this it is gives the report part by part.
>
I am not sure what the problem is.
You get the top 5 SQL statements because of the "<6" part of the code. Would be top 10 if "<11" and so on.
Maybe you have got to format the output a little in SQL*Plus to get it better readable - I leave that up to you :-)
Kind regards
Uwe
http://uhesse.wordpress.com

Similar Messages

  • How to get top SQLs in a time period

    HI, How can identify top SQL over a period of 1-month. Top SQL tab only displays top SQLs in last 24 hours in grid control.
    Neeraj

    AWR is your answer. Find the snapshots from Month old to current or what ever time you want and create a preserved snapshot set. and then create a report.
    That will give you the top 10 sql with in that range.
    AWR can be found under Adminstration tab.
    Naren

  • How to get physical SQL query

    Hi All,
    How to get the physical SQL query for the OBIEE reports.
    Thanks in advance,
    Haree.

    Hi Anitha,
    Thanks for your reply,
    I am getting XML script in log file. (Settings > Administration > Manage Sessions > View Log).
    How to get physical SQL query ?
    Thanks,
    Haree

  • How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"

    How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
    I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
    Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
    I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
    use msdb
    SELECT [JobName] = JOB.name,
    [Step] = HIST.step_id,
    [StepName] = HIST.step_name,
    [Message] = HIST.message,
    [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
    WHEN HIST.run_status = 1 THEN 'Succeeded'
    WHEN HIST.run_status = 2 THEN 'Retry'
    WHEN HIST.run_status = 3 THEN 'Canceled'
    END,
    [RunDate] = HIST.run_date,
    [RunTime] = HIST.run_time,
    [Duration] = HIST.run_duration,
    [Retries] = HIST.retries_attempted
    FROM sysjobs JOB
    INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
    -- CHANGE THIS
    -- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
    ORDER BY HIST.run_date, HIST.run_time

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • How to get top CPU consuming sql oracle 10g

    I can see the top sql by running ASH report. but there is too much infomation. is there a way I can just display TOP SQL section, and filter out other parts? this way I can use it in a shell script, and loop through the database.
    or is there a query can do the ASH job?
    thanks.
    Karl

    Hi,
    What you will do if the EM console bug present?
    As a best pratice, i will do like below
    1) execute the TOP command and you see process consuming high CPU
    2)
    SQL> oradebug setospid <&OSPid>
    SQL> oradebug tracefile_name --This will list the name of tracefile with location
    SQL> oradebug unlimit
    SQL> oradebug Event 10046 trace name context forever, level 12;
    Let it run for 20 mins around
    SQL> oradebug Event 10046 trace name context off;
    SQL> exit
    3) Tkprof with explain plan
    4) check any plan change for that sql
    Kind Regards,
    Rakesh jayappa

  • How to get top 10 records for each option in table prompt?

    Hi,
    I have created one report in which my requirement is to get top 10 highest salaries for each departments. I have created one table prompt which contains the names of all departments. On the salary column I have applied one filter i.e. TOP 10. Currently I am having 3 departments. I want to show the top 10 salaries for each department, but I am getting top 3 from first, 4 from second and 3 from third.They are calculating top 10 salaries based on all departments, not on individual department. How can I get top 10 salaries for each department?

    Hi,
    Use TopN function in your column formula.
    Ex: TOPN("Sales ,5 BY department)
    Thanks,
    Satya

  • How to get the SQL queries based on SQL_ID.

    Hi Experts,
    I want to get the SQL queries based on SQL_ID.
    I have tried the following query,but I am not getting full query.
    [code]SET linesize 132 pagesize 999
    column sql_fulltext format a60 word_wrap
    break on sql_text skip 1
    SELECT   REPLACE (TRANSLATE (sql_text, '0123456789', '999999999'), '9', ''),sql_id
    FROM   dba_hist_sqltext s
    WHERE   s.sql_id = '7tvurftg8zryb';[/code]
    One of my friend said use grid to get full query text.
    Can you please help me how to use grid ,else any other method to get the full query based on SQL_ID.
    Please help me.
    Thanks in advance.

    You have these many options to set, if sql_text is really huge. But better use a tool(TOAD) as it's really helpful and easy to use instead! (See my previous comment).
    column sql_text format A10000
    set echo off
    set head off
    set feed off
    set verify off
    set termout off
    set lines 10000
    set long 1000000
    set trimspool on
    set pages 0
    Thanks!

  • How to get the SQL statement

    I cannot figure how to get the text(SQL statement) from a system view(i guess it is in a system view... but witch??). 'Till now i have the sql_address and the sql_hash_value..
    I know it is possible.. EM does it ... so i should be able to do the same..
    ps:I use 9.2

    v$sql ?

  • How to get the sql id and sql text  for the pid which is completed.

    Hi All,
    I like to know how the get the details of sql_id and sql_text using the proecess which is completed already (ie., no more showing in the top command).
    But I have the details of the process id.
    Database name: 11g
    os: sun os
    thanks
    Edited by: user9354175 on Nov 8, 2010 10:42 AM

    If the session is still connected you might try this:
    - query v$process where spid = os-process-number
    - then join v$process to v$session using ADDR (in process) to PADDR (in session)
    - then look at PREV_SQL_ID in v$session.
    - use that to get the SQL_TEXT in for instance V$SQLAREA.
    Could work, if all info is still in the SGA...

  • How to get TOP 5 results in version 7.3.4?

    Hello,
    I have try to use subquery in a query to get the top 5 result in Oracle version 7.3.4, it seems like not working. Can you please tell me how to get the TOP 5 results with Oracle 7.3.4??
    For example,
    REJECT CATEGORY QUANTITY
    AA 100
    BB 5
    CC 20
    DD 73
    EE 88
    FF 76
    GG 43
    HH 99
    So i want to get the result as AA, HH, EE, FF, DD.
    Thanks.

    I don't have that version available to me and I forgot if rownum was already available. See if this works:
    select * from (
    select category, quantity, rownum rn
    from reject
    order by quantity desc)
    where rn <= 5;
    Note that this is not the same as the TOP posibilities in 9i, but you example seems to suggest this should be enough.
    Also note that on big tables, this query is performing porely because Oracle first needs to sort all records.
    L.

  • How to get top 10 employees in BEx Report

    Hi all,
    I am trying to get top 10 employees who have worked over 50 hrs of overtime in any pay period i choose in query.
    How do i get it ??
    right now my report gives me total of over 50hrs overtime in all chosen pay period employees list.
    Any suggestions ??
    Thank You,
    KSmith

    CAN  SOMEONE PLEASE HELP ME SOLVE THIS PROBLEM ??
    Hi all,
    The problem I have is even though i tried condition for top 10 employees who worked more than 50 hrs.
    My report right now shows all employees overtime under "OT" key figure for each pay period. --> I just want to show employees and overtime which is > 50 for each different pay period
    The condition works only if i display just one pay period...and user dont want it that way. they want to get more than one pay period displayed on the report and should have list of employees who work more than 50 hrs over time. HOW DO I GET THAT ??
    Also there is another key figure count meaning if out of those chosen pay periods there are 3 periods when an employee worked more than 50 hrs of over time then it should show "3". if there 2 pay periods when employee work more than 50 hrs count should display 2 ---> right now i am not able to get that also.
    Please can some one suggest something ??
    Thank You,
    KSmith
    Edited by: Keral Smith on Jul 25, 2008 2:49 PM
    Edited by: Keral Smith on Jul 25, 2008 3:08 PM

  • How to get the sql which executing?

    I want to know the query sql runing in timesten? how can I get it?
    For example, in oracle 9i we can use below sql to get the query sql runinig in oracle.
    1.select OSUSER, PROGRAM, USERNAME, SCHEMANAME, B.Cpu_Time, STATUS, B.SQL_TEXT
    2. from V$SESSION A
    3. LEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS
    4. AND A.SQL_HASH_VALUE = B.HASH_VALUE
    5. order by b.cpu_time desc
    thanks!

    Sorry, there is no way to get this information in TimesTen. You can use internal tracing to see each SQL statement as it is executed but (a) the performance hit is severe and (b) there is no timing or CPU usage information available.
    If you want to know how long a specific SQL statement takes to execute you need to add timing instrumentation to your application code.
    Chris

  • How to get a SQL statement that trigerred a trigger ?

    I'd like to trace all insert and update operations done on a table.
    So, how can I get the SQL statement that triggered a trigger ?
    Thanks

    Use AUDIT to trace all sql statement about table, views etc. (except column) :
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_4007.htm#SQLRF01107
    Or, if you are in 9i or later, you can use DBMS_FGA (you can audit just a column) :
    http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10802/d_fga.htm#ARPLS015
    Nicolas.

  • How to get top 10 actively used TFS projects?

    We have 100+ projects inside a TFS collection, how to find the (say to 10 or 15) most actively used projects? Idealy the activities will include any actions like CI/CO, build, member addition, etc.
    Thanks

    Hi Peter,  
    Thanks for your post.
    As far as I know there’s no a default way to get such top 10 actively team projects report. You should create your custom report using TFS API to achieve that, pleas refer to the discussions in this similar post:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/984d1796-e195-4765-9f55-e2a45bc37c80/how-to-get-a-list-of-active-projects-from-tfs-?forum=tfsgeneral. 
    For this scenario, please submit it to User Voice site at: http://visualstudio.uservoice.com/forums/121579-visual-studio. Microsoft engineers will evaluate them
    seriously.  
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get 'Top Sites' back?

    I downloaded an Installer, but then deleted it, however what i didn't notice was that it had made itself my Safari Homepage, rather than 'Top Sites', how do i get 'Top Sites' back?

    Open Safari and click Preferences on the menu named Safari. On the General tab set "New Windows Open with" and "New Tabs Open with" to Top Sites. It doesn't matter what the Homepage is set to if the above are set to Top Sites.
    If New Windows Open With isn't a choice, go to Apple Menu > System Preferences > General and put a checkmark in front of "Close Windows when Quitting an app."

Maybe you are looking for