如何在Netezza NZSQL中使用制表符分隔符输出文件

编程入门 行业动态 更新时间:2024-10-28 16:30:29
本文介绍了如何在Netezza NZSQL中使用制表符分隔符输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用NZSQL CLI输出某些文件,但无法输出为制表符分隔的文件.可以为在NZ工作的人分享您对以下命令的看法.

I am trying to output some files using NZSQL CLI but not able to output as tab delimited files. Can somebody who has worked on NZ share your thoughts on this below command.

到目前为止已经尝试过:-

Tried so far :-

nzsql -o sample.txt -F= -A -t -c "SELECT * FROM DW_ETL.USER WHERE datasliceid % 20 = 2 LIMIT 5;"

推荐答案

要将$ tab与-F选项一起指定,以将制表符指定为定界符.

To specify tab as the delimiter use $ in conjunction with the -F option.

nzsql -o sample.txt -F $'\t' -A -t -c "SELECT * FROM DW_ETL.USER WHERE datasliceid % 20 = 2 LIMIT 5;"

这在nzsql -h输出中记录.

This is documented in the nzsql -h output.

nzsql -h This is nzsql, the IBM Netezza SQL interactive terminal. Usage: nzsql [options] [security options] [dbname [username] [password]] Security Options: -securityLevel Security Level you wish to request (default: preferredUnSecured) -caCertFile ROOT CA certificate file (default: NULL) Options: -a Echo all input from script -A Unaligned table output mode (-P format=unaligned) -c <query> Run only single query (or slash command) and exit -d <dbname> Specify database name to connect to (default: system) -D <dbname> Specify database name to connect to (default: system) -schema <schemaname> Specify schema name to connect to (default: $NZ_SCHEMA) -e Echo queries sent to backend -E Display queries that internal commands generate -f <filename> Execute queries from file, then exit -F <string> Set field separator (default: "|") (-P fieldsep=) For any binary/control/non-printable character use '$' (e.g., nzsql -F $'\t' // for TAB) ...

如果您有大量数据,建议您改用外部表,因为它们的性能更好.

If you have a lot of data, I'd recommend using external tables instead as they perform better.

CREATE EXTERNAL TABLE '/tmp/sample.txt' USING (DELIMITER '\t') AS SELECT * FROM DW_ETL.USER WHERE datasliceid % 20 = 2 LIMIT 5;

更多推荐

如何在Netezza NZSQL中使用制表符分隔符输出文件

本文发布于:2023-10-26 00:57:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1528617.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:制表符   文件   分隔符   如何在   NZSQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!