Oracle SQL Developer 假脱机输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16722089/
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
Oracle SQL Developer spool output?
提问by mooseman
I am using Oracle SQL Developer 2.1.1.64 to spool the results of a query to a text file Here is what I am running to call the quesry and spool the results
我正在使用 Oracle SQL Developer 2.1.1.64 将查询结果假脱机到文本文件这是我正在运行以调用查询并假脱机结果
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
set verify off
SET ECHO OFF
spool c:\client\output_sql\t_1001_02_0522_.txt
@c:\client\queries\t_1001_02_query;
spool off
Unfortunately, i am getting
不幸的是,我得到
@c:\client\queries\t_1001_02_query
@c:\client\queries\t_1001_02_query
at the top of my output text file and I need to have just the results. I have searched the web for this and have tried a variety of things like: set verify off set termout off
在我的输出文本文件的顶部,我只需要得到结果。我已经在网上搜索过这个并尝试了各种方法,例如:set verify off set termout off
采纳答案by mooseman
I have found that if I save my query(spool_script_file.sql) and call it using this
我发现如果我保存我的查询(spool_script_file.sql)并使用它调用它
@c:\client\queries\spool_script_file.sql as script(F5)
@c:\client\queries\spool_script_file.sql 作为脚本(F5)
My output now is just the results with out the commands at the top.
我现在的输出只是没有顶部命令的结果。
I found this solution on the oracle forums.
我在 oracle 论坛上找到了这个解决方案。
回答by Pvz
For Spooling in Oracle SQL Developer, here is the solution.
对于 Oracle SQL Developer 中的假脱机,这里是解决方案。
set heading on
设置标题
set linesize 1500
设置线宽 1500
set colsep '|'
设置 colsep '|'
set numformat 99999999999999999999
设置数字格式 99999999999999999999
set pagesize 25000
设置页面大小 25000
spool E:\abc.txt
线轴 E:\abc.txt
@E:\abc.sql;
@E:\abc.sql;
spool off
线轴关闭
The hint is :
提示是:
when we spool from sql plus , then the whole query is required.
when we spool from Oracle Sql Developer , then the reference path of the query required as given in the specified example.
当我们从 sql plus spool 时,则需要整个查询。
当我们从 Oracle Sql Developer 假脱机时,则需要指定示例中给出的查询的引用路径。
回答by egarcia
Another way simpler than me has worked with SQL Developer 4 in Windows 7
另一种比我更简单的方法是在 Windows 7 中使用 SQL Developer 4
spool "path_to_file\filename.txt"
query to execute
spool of
You have to execute it as a script, because if not only the query will be saved in the output fileIn the path name I use the double character "\" as a separator when working with Windows and SQL, The output file will display the query and the result.
您必须将其作为脚本执行,因为如果不仅查询将保存在输出文件中,我在使用 Windows 和 SQL 时使用双字符“\”作为分隔符的路径名中,输出文件将显示查询和结果。
回答by tbone
You can export the query results to a text file (or insert statements, or even pdf) by right-clicking on Query Result row (any row) and choose Export
您可以通过右键单击查询结果行(任何行)并选择导出来将查询结果导出到文本文件(或插入语句,甚至 pdf)
using Sql Developer 3.0
使用 Sql Developer 3.0
See SQL Developer downloadsfor latest versions
请参阅SQL Developer 下载以获取最新版本
回答by Jeff
I was trying things to duplicate the spools you get from sqlplus. I found the following and hope it helps:
我正在尝试复制您从 sqlplus 获得的线轴。我发现了以下内容,希望对您有所帮助:
Create your sql script file ie:
创建您的 sql 脚本文件,即:
Please note the echo and serveroutput.
请注意 echo 和 serveroutput。
Test_Spool.SQL
测试_Spool.SQL
Spool 'c:\temp\Test1.txt';
set echo on;
set serveroutput on;
declare
sqlresult varchar2(60);
begin
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') into sqlresult from dual;
dbms_output.put_line('The date is ' || sqlresult);
end;
/
Spool off;
set serveroutput off;
set echo off;
Run the script from another worksheet:
从另一个工作表运行脚本:
@TEST_Spool.SQL
My output from the Test1.txt
我从 Test1.txt 的输出
set serveroutput on
declare
sqlresult varchar2(60);
begin
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') into sqlresult from dual;
dbms_output.put_line('The date is ' || sqlresult);
end;
anonymous block completed
匿名块完成
The date is 2016-04-07 09:21:32
日期是 2016-04-07 09:21:32
Spool of
线轴