How to Import a CSV

If you have a CSV file you can import into a table usig the copy command of Postgres. There are two flavors of the command: \copy and copy. Copy runs on server side, then it expects the csv file to be on the postgres server side file system. On the other hand \copy is for csv files stored on the client side file system, and is a command of the psql SQL client.

-- The file and the table have the same quantity of columns
\copy employee from 'employee.csv' csv;

-- If you want to only import certain columns and the file has headers 
\copy employee (emp_id, last_name, first_name) from 'employee.csv' csv header;

IN THIS PAGE