简体   繁体   中英

unload data to s3 with new line characters redshift

i am trying to export table from redshift to s3 using unload command command :

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

is there any way to replace new line to \\n or to add a end of line character

You should be removing escape , and just try ADDQUOTE Option, it will produce correct CSV. As "" will instruct your CSV reader to treat \\n as verbiage rather than 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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