[英]Exporting sql request to csv instead of table data
I need to export data from my Oracle table to a csv file. 我需要将数据从Oracle表导出到csv文件。 Below is the code that I am running under SQL Developer : 下面是我在SQL Developer下运行的代码:
set termout off
set serveroutput off
set feedback off
set colsep ';'
set lines 100000
set pagesize 0
set echo off
set feedback off
spool D:\myfile.csv
select *
from Employee;
spool off
However the output of the above code in the csv file is : 但是,上面的代码在csv文件中的输出是:
select * from Employee; 从员工中选择*;
I want the data of the Employee table to be in the csv, not the sql statement. 我希望Employee表的数据在csv中,而不是sql语句中。 Any idea what might be wrong in the above code? 知道上面的代码有什么问题吗? Thanks. 谢谢。
save your sql in a file emp.sql
in a directory D:\\scripts
and use like below; 将您的sql保存在目录D:\\scripts
中的emp.sql
文件中,并使用如下所示;
set term off
set feed off
spool D:\myfile.csv
@D:\scripts\emp.sql
spool off
You're in SQL Developer, so you don't have to write so much code. 您正在使用SQL Developer,因此不必编写太多代码。
SET SQLFORMAT csv
SPOOL C:\your_file.csv
select * from whatever;
spool off
Run with F5 使用F5运行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.