TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashCpanelLinux

How to import data from csv file to PostgreSQL database

We can use psql command to import data from csv file to PostgreSQL database.

#psql -d DATABASE -c "COPY SCHEMA.TABLE FROM 'FILE-LOCATION' DELIMITER ',' CSV HEADER;"

Where,

DATABASE need to be replaced by database name.
SCHEMA need to be replaced by schema name.
TABLE need to be replaced by table name.
FILE-LOCATION need to be replaced by the full path to the csv file.

That's all…

Leave a Reply