Roshan Nagpure
Roshan Nagpure

Reputation: 124

Unloading Multiple tables in AWS Redshift

I have to implement a CR, where i have to unload around 180 tables of Redshift cluster. I have all Unload command, which I'm going to execute one by one.

It would be great if I do get some work-around over this issue.

Reference document: Unloading Data to Amazon S3

Sample command:

unload ('select column1, column2 from table') to 's3://prod/audi/history/20150914/fact_invite2_audi_'
credentials '<>' 
MANIFEST GZIP ESCAPE DELIMITER AS ',' ;

Upvotes: 0

Views: 3956

Answers (2)

TheDataGuy
TheDataGuy

Reputation: 3118

I have recently implemented this with the help of stored procedure.

What we’ll achieve with this?

  1. Unload many tables to S3.
  2. Unload all the tables in a specific schema.
  3. Unload specific tables in any schema.
  4. All the tables in all the schema.

All detailed steps are here: https://thedataguy.in/redshift-unload-multiple-tables-schema-to-s3/

Upvotes: 0

John Rotenstein
John Rotenstein

Reputation: 270184

The Amazon Redshift UNLOAD command only exports the results of one SELECT statement. The statement can reference multiple Redshift tables, but will not export the data as separate outputs.

Some options:

  • Send one request with multiple UNLOAD statements, separated by semi-colons. They will be executed sequentially, but it's easier to issue.
  • Run simultaneous requests. Each would need a separate JDBC connection, but the requests would run concurrently, based upon Workload Management queue configurations.

Upvotes: 2

Related Questions