psql -d appdb -c "\copy users FROM '/tmp/users.csv' DELIMITER ',' CSV HEADER"

Category: Databases & SQL

psql -d appdb -c "\copy users FROM '/tmp/users.csv' DELIMITER ',' CSV HEADER"

Import a CSV file into a table

Loads the CSV into the users table, matching columns by order, not name; the header row is skipped. An error aborts the whole import. Use COPY ... FROM for files that live on the server.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.