Redshift SQL : COPY



COPY

- It appends the data in the table.
- It can take the data from S3 file, EMR cluster and Dynamo DB.


Loading data from S3 File

COPY schemaname.tablename FROM 's3://bucketname/foldername/filename.txt' CREDENTIALS 'aws_access_key_id=ASFGSDFGSGUW5SHK3Q;aws_secret_access_key=PasdfSafasdFASdfaSDqw5QWa519o2blB3' delimiter '\t' REGION 'us-west-2' timeformat 'YYYY-MM-DD HH:MI:SS' IGNOREHEADER 1 ;


- If the  s3 bucket is not in the same region, then you have to specify the REGION
- IGNOREHEADER is to omit x number of lines from the file
- TIMEFORMAT specifies the the format of the data in the file which will be loaded into timeformat datatype.
- DELIMITER specifies the delmiter used in the file
- The credentials you specify should have GetObject and ListBucket privelage for the s3 bucket





Comments