1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Records of last executed commands

Discussion in 'SQL PL/SQL' started by deniz_durmus, Sep 15, 2010.

  1. deniz_durmus

    deniz_durmus Guest


    I have some troubles when I try to retrieve last executed queries in a database.
    For example;

    I run the script below:

    Code (SQL):
    SELECT DISTINCT t.first_load_time, t.sql_text, t.last_load_time, s.username
    FROM v_$sql t, v$session s
    WHERE s.username='SYS'
    And as a result, I retrieve the queries executed by SYS user. But the problem is that, if SYS user executed the same query more than once,
    only the very first record is shown.

    It is like this,

    SYS user executes "select * from table_abc" at 10:54:35, and after that SYS executes the same query at 13:45:55. and after running
    the query above, I can only see the record which was executed at 10:54:35. I need to see the both results.

    Can anyone tell me what I should do or change in the query above?
  2. zargon

    zargon Community Moderator Forum Guru

    Likes Received:
    Trophy Points:
    Aurora, CO
    You're asking for distinct results, so why are you surprised that a query executed multiple times only displays once? Remove the 'distinct' and see what is returned.
  3. Sadik

    Sadik Community Moderator Forum Guru

    Likes Received:
    Trophy Points:
    As David said, it's because of the DISTINCT clause in your query. Remove that.