1

So I worked on a bunch of queries yesterday, and before I could get to exporting the results to an external file, my database went down. Is there any way to see the results of your past few queries in SQL Developer? I know there are ways to see your past queries, but I am looking for the results of my queries. Finding them would save me and my team a lot of rework.

Any help would be much appreciated. Thanks!

Edit: I am asking how to find the results of the SQL queries I ran yesterday. Not the queries themselves.

lebowski
  • 1,031
  • 2
  • 20
  • 37
  • What did you do to SQL Developer when the DB went down? Then: What are your SQL Developer settings? Two of them in particular: How many rows of output do you show at a time? And: Do you show all query results in a single tab, a new query output overwriting the previous one? Or does each query open a new output tab? Both "favorable" settings (show many rows, and open a new tab for each query) are **not** the defaults. –  Nov 17 '17 at 15:01
  • Possible duplicate of [Find out the history of SQL queries](https://stackoverflow.com/questions/14830875/find-out-the-history-of-sql-queries) – XING Nov 17 '17 at 15:23
  • 1
    bring your database back up - good luck with that - and then you can try flashback query - so you run the query again, but it runs as the data was when you ran them previously https://docs.oracle.com/cd/E11882_01/appdev.112/e41502/adfns_flashback.htm#ADFNS01003 – thatjeffsmith Nov 17 '17 at 16:22
  • 1
    No it is not possible. SQLDeveloper doesn't save results of queries. – krokodilko Nov 17 '17 at 16:25

1 Answers1

0

Use a SELECT statement with an AS OF clause. This retrieves data as it existed at some point in the past.

For example, this query returns the record from current state for Chung.

SELECT * FROM employees
     WHERE last_name = 'Chung';

And below query retrieves the state of the record for Chung at 9:30AM, April 4, 2004:

SELECT * FROM employees
  AS OF TIMESTAMP
   TO_TIMESTAMP('2004-04-04 09:30:00', 'YYYY-MM-DD HH:MI:SS')
     WHERE last_name = 'Chung';

You can also restore like this:

INSERT INTO employees
  (SELECT * FROM employees
     AS OF TIMESTAMP
       TO_TIMESTAMP('2004-04-04 09:30:00', 'YYYY-MM-DD HH:MI:SS')
         WHERE last_name = 'Chung');

Drag the queries from SQL history to worksheet and modify with AS OF clause. Refer to the source of this answer for more info: https://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_flashback.htm#g1025568

rd10
  • 1,599
  • 2
  • 10
  • 27