I'm using Oracle SQL Developer 3.0. Trying to figure out how to export a query result to a text file (preferably CSV). Right clicking on the query results window doesn't give me any export options.
我使用的是Oracle SQL Developer 3.0。试图弄清楚如何将查询结果导出到文本文件(最好是CSV)。右键单击查询结果窗口不会给我任何导出选项。
5 个解决方案
#1
312
Version I am using
我用的版本
Update 5th May 2012
2012年5月5日更新
Jeff Smith has blogged showing, what I believe is the superior method to get CSV output from SQL Developer. Jeff's method is shown as Method 1 below:
Jeff Smith已经在博客上展示了,我认为是获得SQL开发人员的CSV输出的高级方法。Jeff的方法如下所示:
Method 1
方法1
Add the comment /*csv*/
to your SQL query and run the query as a script (using F5 or the 2nd execution button on the worksheet toolbar)
添加注释/*csv*/到SQL查询,并将查询作为脚本运行(在工作表工具栏上使用F5或第二个执行按钮)
That's it.
就是这样。
Method 2
方法2
Run a query
运行一个查询
Right click and select unload.
右键单击并选择unload。
Update. In Sql Developer Version 3.0.04 unload has been changed to export Thanks to Janis Peisenieks for pointing this out
更新。在Sql Developer版本3.0.04卸载中,由于Janis Peisenieks指出了这一点,所以已经更改了出口。
Revised screen shot for SQL Developer Version 3.0.04
为SQL Developer版本3.0.04修改了屏幕截图。
From the format drop down select CSV
从下拉式选择CSV。
And follow the rest of the on screen instructions.
并跟随屏幕上的其他指令。
#2
36
Not exactly "exporting," but you can select the rows (or Ctrl-A to select all of them) in the grid you'd like to export, and then copy with Ctrl-C.
不完全是“导出”,但是您可以在您想要导出的网格中选择行(或者Ctrl-A选择所有的行),然后使用Ctrl-C复制。
The default is tab-delimited. You can paste that into Excel or some other editor and manipulate the delimiters all you like.
缺省值是一样。您可以将其粘贴到Excel或其他编辑器中,并对分隔符进行操作。
Also, if you use Ctrl-Shift-C instead of Ctrl-C, you'll also copy the column headers.
另外,如果您使用Ctrl-Shift-C而不是Ctrl-C,您也会复制列标题。
#3
25
FYI, you can substitute the /*csv*/
for other formats as well including /*xml*/
and /*html*/
. select /*xml*/ * from emp
would return an xml document with the query results for example. I came across this article while looking for an easy way to return xml from a query.
FYI,你可以替换/*csv*/其他格式,包括/*xml*/和/*html*/。从emp中选择/*xml*/ *将返回一个带有查询结果的xml文档。在寻找从查询返回xml的简单方法时,我遇到了这篇文章。
#4
2
FYI to anyone who runs into problems, there is a bug in CSV timestamp export that I just spent a few hours working around. Some fields I needed to export were of type timestamp. It appears the CSV export option even in the current version (3.0.04 as of this posting) fails to put the grouping symbols around timestamps. Very frustrating since spaces in the timestamps broke my import. The best workaround I found was to write my query with a TO_CHAR() on all my timestamps, which yields the correct output, albeit with a little more work. I hope this saves someone some time or gets Oracle on the ball with their next release.
对于任何遇到问题的人来说,在CSV的时间戳导出中有一个bug,我只是花了几个小时来处理。我需要导出的一些字段是类型时间戳。即使在当前版本(这篇文章的3.0.04)中,也出现了CSV导出选项,但没有将分组符号放在时间戳周围。非常令人沮丧,因为时间戳中的空格破坏了我的导入。我找到的最佳解决方案是用TO_CHAR()在所有时间戳上编写查询,这将产生正确的输出,尽管还需要做一些工作。我希望这能节省一些时间,或者在下次发布的时候让神谕。
#5
1
CSV Export does not escape your data. Watch out for strings which end in \
because the resulting \"
will look like an escaped "
and not a \
. Then you have the wrong number of "
and your entire row is broken.
CSV导出不会泄漏您的数据。注意字符串的结尾,因为结果\“看起来像一个转义的”而不是一个\。然后你就有了错误的数字,你的整行都被打破了。
#1
312
Version I am using
我用的版本
Update 5th May 2012
2012年5月5日更新
Jeff Smith has blogged showing, what I believe is the superior method to get CSV output from SQL Developer. Jeff's method is shown as Method 1 below:
Jeff Smith已经在博客上展示了,我认为是获得SQL开发人员的CSV输出的高级方法。Jeff的方法如下所示:
Method 1
方法1
Add the comment /*csv*/
to your SQL query and run the query as a script (using F5 or the 2nd execution button on the worksheet toolbar)
添加注释/*csv*/到SQL查询,并将查询作为脚本运行(在工作表工具栏上使用F5或第二个执行按钮)
That's it.
就是这样。
Method 2
方法2
Run a query
运行一个查询
Right click and select unload.
右键单击并选择unload。
Update. In Sql Developer Version 3.0.04 unload has been changed to export Thanks to Janis Peisenieks for pointing this out
更新。在Sql Developer版本3.0.04卸载中,由于Janis Peisenieks指出了这一点,所以已经更改了出口。
Revised screen shot for SQL Developer Version 3.0.04
为SQL Developer版本3.0.04修改了屏幕截图。
From the format drop down select CSV
从下拉式选择CSV。
And follow the rest of the on screen instructions.
并跟随屏幕上的其他指令。
#2
36
Not exactly "exporting," but you can select the rows (or Ctrl-A to select all of them) in the grid you'd like to export, and then copy with Ctrl-C.
不完全是“导出”,但是您可以在您想要导出的网格中选择行(或者Ctrl-A选择所有的行),然后使用Ctrl-C复制。
The default is tab-delimited. You can paste that into Excel or some other editor and manipulate the delimiters all you like.
缺省值是一样。您可以将其粘贴到Excel或其他编辑器中,并对分隔符进行操作。
Also, if you use Ctrl-Shift-C instead of Ctrl-C, you'll also copy the column headers.
另外,如果您使用Ctrl-Shift-C而不是Ctrl-C,您也会复制列标题。
#3
25
FYI, you can substitute the /*csv*/
for other formats as well including /*xml*/
and /*html*/
. select /*xml*/ * from emp
would return an xml document with the query results for example. I came across this article while looking for an easy way to return xml from a query.
FYI,你可以替换/*csv*/其他格式,包括/*xml*/和/*html*/。从emp中选择/*xml*/ *将返回一个带有查询结果的xml文档。在寻找从查询返回xml的简单方法时,我遇到了这篇文章。
#4
2
FYI to anyone who runs into problems, there is a bug in CSV timestamp export that I just spent a few hours working around. Some fields I needed to export were of type timestamp. It appears the CSV export option even in the current version (3.0.04 as of this posting) fails to put the grouping symbols around timestamps. Very frustrating since spaces in the timestamps broke my import. The best workaround I found was to write my query with a TO_CHAR() on all my timestamps, which yields the correct output, albeit with a little more work. I hope this saves someone some time or gets Oracle on the ball with their next release.
对于任何遇到问题的人来说,在CSV的时间戳导出中有一个bug,我只是花了几个小时来处理。我需要导出的一些字段是类型时间戳。即使在当前版本(这篇文章的3.0.04)中,也出现了CSV导出选项,但没有将分组符号放在时间戳周围。非常令人沮丧,因为时间戳中的空格破坏了我的导入。我找到的最佳解决方案是用TO_CHAR()在所有时间戳上编写查询,这将产生正确的输出,尽管还需要做一些工作。我希望这能节省一些时间,或者在下次发布的时候让神谕。
#5
1
CSV Export does not escape your data. Watch out for strings which end in \
because the resulting \"
will look like an escaped "
and not a \
. Then you have the wrong number of "
and your entire row is broken.
CSV导出不会泄漏您的数据。注意字符串的结尾,因为结果\“看起来像一个转义的”而不是一个\。然后你就有了错误的数字,你的整行都被打破了。