将SQL请求导出到CSV而不是表数据 [英] Exporting sql request to csv instead of table data

查看:77
本文介绍了将SQL请求导出到CSV而不是表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将数据从Oracle表导出到csv文件. 下面是我在SQL Developer下运行的代码:

I need to export data from my Oracle table to a csv file. Below is the code that I am running under 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

然而,上面的代码在csv文件中的输出是:

However the output of the above code in the csv file is :

选择* 来自员工;

select * from Employee;

我希望Employee表的数据在csv中,而不是sql语句中. 知道上面的代码有什么问题吗?谢谢.

I want the data of the Employee table to be in the csv, not the sql statement. Any idea what might be wrong in the above code? Thanks.

推荐答案

将您的sql保存在目录D:\scripts中的文件emp.sql中,并按以下方式使用;

save your sql in a file emp.sql in a directory D:\scripts and use like below;

set term off
set feed off

spool D:\myfile.csv

@D:\scripts\emp.sql

spool off

这篇关于将SQL请求导出到CSV而不是表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆