Dump Redshift Data To A Single CSV File In S3 With UNLOAD
unload ('SELECT * FROM schema_name.table_name') to 's3://bucket_name/folder_name/output.csv_' iam_role 'arn:aws:iam::123456789012:role/RoleName' allowoverwrite parallel off;
This will dump the file to:
- By default, the output separator is the
|character instead of a comma. If you need a comma, or some other character, you can change it with the
- To make a tab delimited file, us
delimiter as '\t'
allowoverwritewill let Redshift overwrite the file each time the SQL is run.
parallel offis what tells Redshift to a single file instead of creating multiple files.
- As of May 2022, there isn't a way to dump a CSV file and have it land with a
.csvextension directly. It always adds the
- If the file is larger than 6.2GB another file will be created at every 6.2GB of size interval