简体   繁体   English

使用新行字符redshift将数据卸载到s3

[英]unload data to s3 with new line characters redshift

i am trying to export table from redshift to s3 using unload command command : 我试图使用unload命令将表从redshift导出到s3:

unload ('SELECT * FROM table where id = 4') TO 's3://path/temp/table1'
 credentials 'aws_access_key_id="ahsvdgsfadhsagdffjh;aws_secret_access_key=ahgsdasdhgsahdgsahdgsahdgsahgsa' delimiter '|' NULL
AS
'\\N' escape;

one of the field in my table contains new line so the csv generated breaks into two lines 我表中的字段之一包含新行,因此生成的csv分为两行

is there any way to replace new line to \\n or to add a end of line character 有没有办法将新行替换为\\ n或添加行尾字符

You should be removing escape , and just try ADDQUOTE Option, it will produce correct CSV. 您应该删除escape ,然后尝试使用ADDQUOTE Option,它将产生正确的CSV。 As "" will instruct your CSV reader to treat \\n as verbiage rather than newline . ""将指示您的CSV阅读器将\\n视作惯用语而不是newline

UNLOAD ('SELECT * FROM table where id = 4') 
TO 's3://path/temp/table1'
credentials aws_access_key_id="ahsvdgsfadhsagdffjh;
    aws_secret_access_key=ahgsdasdhgsahdgsahdgsahdgsahgsa' 
delimiter '|' 
NULL AS '\\N' ADDQUOTE;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM