在DB2中将select语句的结果导出为CSV格式 [英] Exporting result of select statement to CSV format in DB2

查看:1484
本文介绍了在DB2中将select语句的结果导出为CSV格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将选择状态的结果导出到CSV文件,就像在MySQL中一样。

Is there any way by which we can export the result of a select statment to CSV file, just like in MySQL.

MySQL命令;

SELECT col1,col2,coln into OUTFILE  'result.csv' FIELDS TERMINATED BY ',' FROM testtable t;


推荐答案

您可以从DB2命令行处理器(CLP)或从SQL应用程序内调用 ADMIN_CMD 存储过程

You can run this command from the DB2 command line processor (CLP) or from inside a SQL application by calling the ADMIN_CMD stored procedure

EXPORT TO result.csv OF DEL MODIFIED BY NOCHARDEL SELECT col1, col2, coln FROM testtable;

有很多选项 IMPORT EXPORT 可用于创建满足您需要的数据文件。 NOCHARDEL 限定符将禁止在每个字符列周围出现的双引号字符。

There are lots of options for IMPORT and EXPORT that you can use to create a data file that meets your needs. The NOCHARDEL qualifier will suppress double quote characters that would otherwise appear around each character column.

请记住, SELECT 语句可以用作导出的源,包括连接甚至递归SQL。如果在 SELECT 语句中指定 ORDER BY ,导出实用程序还将遵循排序顺序。

Keep in mind that any SELECT statement can be used as the source for your export, including joins or even recursive SQL. The export utility will also honor the sort order if you specify an ORDER BY in your SELECT statement.

这篇关于在DB2中将select语句的结果导出为CSV格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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