Recover unsaved SQL query Scripts in Oracle SQL Developer

Matt picture Matt · Nov 11, 2014 · Viewed 58k times · Source

I know how to do this in SQL Server thanks to this clever bit of code

Use <database>
SELECT execquery.last_execution_time AS [Date Time], execsql.text AS [Script] 
FROM sys.dm_exec_query_stats AS execquery
CROSS APPLY sys.dm_exec_sql_text(execquery.sql_handle) AS execsql
ORDER BY execquery.last_execution_time DESC

SOURCE: Recover unsaved SQL query scripts

Is there a way to do this in Oracle SQL Developer?

Answer

Matt picture Matt · Nov 11, 2014

If you have the privileges then:

SELECT * FROM v$sql

If not then press F8 to bring up a list of previously ran queries.