Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Last SQL commands

Re: Last SQL commands

From: Yong Huang <yong321_at_yahoo.com>
Date: 17 May 2002 10:51:38 -0700
Message-ID: <b3cb12d6.0205170951.2ac2806a@posting.google.com>


davide_at_yahoo.com wrote in message news:<ac30ov$mdtdg$5_at_ID-18487.news.dfncis.de>...
> "Michal Beneš" <benes_at_sbt.cz> wrote:
> > I need to know, how to find out which SQL command (whole with values of
> > variables) have come to Oracle server as last.
>
> You can look in the V_$sessioni and v_$sqltext views that holds a
> snapshot of the SGA. Try using
>
> select
> to_char(logon_time,'DD-MM-YYYY HH:mm'),
> machine,
> status,
> sql_text
> from
> sys.v_$sqltext_with_newlines, sys.v_$session
> where
> SQL_ADDRESS=ADDRESS and
> SQL_HASH_VALUE=HASH_VALUE
> order by
> sid desc, piece;

That doesn't look right. He wants the last SQL that ran in Oracle. logon_time has nothing to do with it. v$sql.FIRST_LOAD_TIME records the time the SQL was first loaded. Still not exactly what he wants (which I think is impossible unless auditing is on), but it's closer. Of course if that exactly same SQL was run again, the FIRST_LOAD_TIME won't change; EXECUTIONS increments though.

Yong Huang Received on Fri May 17 2002 - 12:51:38 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US