What is the COPY command to load data into the table sales_agg from an S3 location?
π‘ Model Answer
The COPY command in Amazon Redshift loads data from external sources such as Amazon S3, DynamoDB, or EMR into a Redshift table. A typical syntax for loading a CSV file into the table sales_agg would be:
COPY sales_agg
FROM 's3://your_bucket/bronze/sales_data.csv'
IAM_ROLE 'arn:aws:iam::123456789012:role/RedshiftCopyRole'
FORMAT AS CSV
DELIMITER ','
IGNOREHEADER 1;
This command tells Redshift to read the file from the specified S3 URI, use the provided IAM role for authentication, interpret the file as CSV with a comma delimiter, and skip the header row. The COPY command is highly parallelized, making it much faster than inserting rows one by one.
This answer was generated by AI for study purposes. Use it as a starting point β personalize it with your own experience.
π€ Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers β invisible to screen sharing.
Get Assisting AI β Starts at βΉ500