0
0
PostgreSQLquery~10 mins

COPY command for bulk data loading in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load data from a CSV file into the table.

PostgreSQL
COPY users FROM '[1]' DELIMITER ',' CSV;
Drag options to blanks, or click blank then click option'
A/path/to/file.csv
Busers.csv
Cdata.txt
D/data/users.csv
Attempts:
3 left
💡 Hint
Common Mistakes
Using a file name without a path when the file is not in the default directory.
Using a text file instead of a CSV file.
2fill in blank
medium

Complete the code to specify that the CSV file has a header row.

PostgreSQL
COPY products FROM '/data/products.csv' DELIMITER ',' CSV [1];
Drag options to blanks, or click blank then click option'
AWITH HEADER
BHEADER
CHEADERS
DFIRSTROW
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'WITH HEADER' which is invalid syntax.
Forgetting to specify HEADER when the CSV has column names.
3fill in blank
hard

Fix the error in the COPY command to load data from a CSV file with tab delimiter.

PostgreSQL
COPY sales FROM '/data/sales.csv' DELIMITER [1] CSV;
Drag options to blanks, or click blank then click option'
A'\t'
B,
C'\n'
D';'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a comma or semicolon instead of tab.
Not using quotes around the delimiter.
4fill in blank
hard

Fill both blanks to load data from a CSV file with semicolon delimiter and skip the header row.

PostgreSQL
COPY inventory FROM '/data/inventory.csv' DELIMITER [1] CSV [2];
Drag options to blanks, or click blank then click option'
A';'
BHEADER
CWITH HEADER
D','
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma as delimiter instead of semicolon.
Using 'WITH HEADER' which is invalid syntax.
5fill in blank
hard

Fill all three blanks to load data from a CSV file with pipe delimiter, skip header, and specify NULL values as empty strings.

PostgreSQL
COPY orders FROM '/data/orders.csv' DELIMITER [1] CSV [2] NULL [3];
Drag options to blanks, or click blank then click option'
A'|'
BHEADER
C''
D'NULL'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NULL' as a string instead of empty string for NULL.
Forgetting to quote the delimiter character.