How to Import CSV file to a table in PostgreSQL?

1. Using SQL command

You can run this command to import CSV file:

COPY table_name FROM '/path_to_csv_file.csv' WITH FORMAT csv;


COPY table_name FROM '/path_to_csv_file.csv' DELIMITERS ',' CSV;

Keep in mind that you have to keep the column names on the csv file the same as columns of the table.

2. Using TablePlus

In TablePlus, you can import csv via the GUI.

To import a CSV file to a current table:

  • Choose File > Import > From CSV... from the menu bar
  • Right-click on the table in the left sidebar or right-click in the data content and choose Import CSV

Import Data

After importing, press Command + R to reload current workspace and see newly imported data.

Need a good GUI tool for PostgreSQL? Check out TablePlus. It’s native, beautiful, and available for free.

Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS.

TablePlus GUI Tool PostgreSQL