在 Oracle SQL Developer 中恢复未保存的 SQL 查询脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26861130/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Recover unsaved SQL query Scripts in Oracle SQL Developer
提问by Matt
I know how to do this in SQL Server thanks to this clever bit of code
由于这段巧妙的代码,我知道如何在 SQL Server 中执行此操作
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
来源: 恢复未保存的 SQL 查询脚本
Is there a way to do this in Oracle SQL Developer?
有没有办法在 Oracle SQL Developer 中做到这一点?
回答by Matt
If you have the privileges then:
如果您有特权,那么:
SELECT * FROM v$sql
If not then press F8to bring up a list of previously ran queries.
如果没有,则按F8以调出以前运行的查询列表。
回答by mmmmmpie
Thishas saved my butt several times.
这已经多次救了我的屁股。
Hi guys, its realy a problem when you lose unsaved code. For about a month I have been working on a big procedure, and forgot to save the code in SVN. If you read this and remember have such unsaved code, commit it immediately! :) Because everything could happen with your test db. Ok. you're lucky if you were using Oracle SQL Developer, because this program has a great feature - it saves your code in its sql history inspite of eating a big party of your RAM. Open your file explorer and locate this folder:
C:\Users\%USERNAME%\AppData\Roaming\SQL Developer\SqlHistory
You'll find a lot of xml files, and if you're twice lucky, you'll find your lost code. Its wonderful. :) . If you're using another program, try to find feature like this and maybe it helps you. My condolences if this post doesn't help you, in any case, try to find something good among the next: 1) write your code again, and it will be better than before as you did it once 2) commit your code, so you'll not face such problem in the future
大家好,当您丢失未保存的代码时,这确实是一个问题。大概一个月我一直在做一个大程序,忘了把代码保存在SVN中。如果您阅读本文并记得有这样的未保存代码,请立即提交!:) 因为任何事情都可能发生在您的测试数据库上。好的。如果您使用的是 Oracle SQL Developer,那么您很幸运,因为该程序有一个很棒的功能 - 尽管吃了一大堆 RAM,它仍将您的代码保存在其 sql 历史记录中。打开文件资源管理器并找到此文件夹:
C:\Users\%USERNAME%\AppData\Roaming\SQL Developer\SqlHistory
您会发现很多 xml 文件,如果幸运的话,您会找到丢失的代码。它的美妙。:) 。如果您正在使用其他程序,请尝试找到这样的功能,也许它会对您有所帮助。如果这篇文章没有帮助你,我表示哀悼,无论如何,尝试在下一个中找到一些好的东西:1)再次编写你的代码,它会比以前更好,就像你曾经做过的那样 2)提交你的代码,所以你以后不会遇到这样的问题
回答by Alberto Cerqueira
回答by Stephen C
This is using SQLDeveloper's history, like in Matt's answer, but if you want to search through the history files for specific query fragments you remember, they are located as .xml files in /home/username/.sqldeveloper/SqlHistory
. From there, enter:
这是使用 SQLDeveloper 的历史记录,就像在 Matt 的回答中一样,但是如果您想在历史记录文件中搜索您记得的特定查询片段,它们位于 .xml 文件中/home/username/.sqldeveloper/SqlHistory
。从那里,输入:
find -type f -mtime -1 -print0 | xargs -0 grep -l <text>
find -type f -mtime -1 -print0 | xargs -0 grep -l <text>
(where -mtime -1
means no sooner than one day ago).
(其中-mtime -1
意味着不早于一天前)。