Skip to content

Instantly share code, notes, and snippets.

@agalea91
Created April 21, 2021 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agalea91/73031476db2afa1271e106d11654d85c to your computer and use it in GitHub Desktop.
Save agalea91/73031476db2afa1271e106d11654d85c to your computer and use it in GitHub Desktop.

Unload to s3

unload ('select * from schema.table') 
to 's3://path/to/s3/folder/'
-- iam_role 'arn:aws:iam::<aws-account-id>:role/<role-name>'
-- credentials 'aws_access_key_id=<key>;aws_secret_access_key=<secret>'
allowoverwrite
format as csv;

Create destination table

create table new_schema.new_table (
  ...
);

Copy into table from s3

copy schema.table from 's3://path/to/s3/folder/'
-- iam_role 'arn:aws:iam::<aws-account-id>:role/<role-name>'
-- credentials 'aws_access_key_id=<key>;aws_secret_access_key=<secret>'
format as csv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment