google-site-verification=ECX1M6_Vb39ty4VtQDXQce6wOjmPTxSettd3hTIZb9Q

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

random

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

Output:

 
Note:
  • 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 PM Rating: 5

1 comment:

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

    ReplyDelete

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.