【问题标题】:How do I spool to a CSV file using SQL Developer?如何使用 SQL Developer 假脱机到 CSV 文件?
【发布时间】:2016-10-24 09:34:30
【问题描述】:

我有这种脚本,我想将最终输出假脱机到 csv 文件。你能帮忙吗?

with first_sub as
select etc
,
second_sub as
select etc

select first_column from first_sub* first_column from second_sub etc.

....................... ..基本上,我有 2 个或更多子查询,我在“最终查询”中进行数学运算 我需要的是能够将输出作为 csv 假脱机。

抱歉,我无法发布任何特定代码

好的,澄清一下,我已经可以后台处理“简单”查询 即`select *from employees'

我有的是这样的

    with sub_1 as 
    select * from employees
    ,
    sub_2 as 
    select * from other_employees

select something from sub1 * something_else from sub_2

最后一点是我想要取出的 .csv 文件

【问题讨论】:

  • 欢迎来到 SO。请先发布正确的查询,然后我们可以处理 csv 问题。另外,请发布您需要假脱机的字段类型(您有日期,数字,...?)
  • 分享正确的查询和尽可能多的信息总是有帮助的......

标签: sql oracle oracle-sqldeveloper


【解决方案1】:

-- SQL 开发者 您可以在 SQL 开发人员中使用 /*csv*/ 提示。正如@Aleksej 建议的那样,您可以查看链接线程以获取更多选项。

select /*csv*/ * from employees; 

--SQL Plus

set feedback off
set heading on
set underline off
set colsep ','

spool 'mytab.csv'
select * from tab;
spool off

【讨论】:

  • SQLPlus 代码示例也将在 SQL Developer 中运行,没有设置的下划线
猜你喜欢
  • 1970-01-01
  • 2013-05-19
  • 1970-01-01
  • 2021-10-11
  • 2021-07-13
  • 2010-10-13
  • 1970-01-01
  • 1970-01-01
  • 2021-09-29
相关资源
最近更新 更多