How to import data from .CSV in PostGres table in a simple way?

Importing data from a CSV file into a Postgres table

In this post I will explain how to import .CSV file bulk data into Postgres table. Here we use COPY command to copy data between a file and a table in PostgreSQL.

In a Query: I create a table named Sample_Test using below Query

create table,how to create table in PostgreSQL

And I have a .CSV data file with all column names available in our table.

Copy data from .CSV to postgres table

Now execute the below query to copy data from .CSV file to the table Sample_Test.

To verify execute the select query.

Select * from Sample_Test


  • All the columns should be in sequence
How to import data from .CSV in PostGres table in a simple way? Reviewed by Ravi Kumar on 2:23:00 PM Rating: 5


  1. what do you do if the csv file doesn't live on the db server?

  2. Thank you so much for this article. I've been googling for the past hour for a straight forward answer and came accross this, and it works perfectly


All Rights Reserved by Etechpulse © 2012 - 2017
Powered By Blogger

Contact Form


Email *

Message *

Powered by Blogger.