0

Here I need to insert huge records to my database tables. How can I do that in PostgreSQL 9.3 version?

Example:

 /* Table creation */

 create table tabletest(slno int,name text,lname text, address text, city text);

 /* Records insertion */

 insert into tabletest values -- Here i need to insert thousands of records in a bulk.
5
  • 1
    Where does the data come from? Is each individual record large, or is it just many records? What exactly is the problem in your current approach of inserting the data? Commented Jun 5, 2014 at 10:04
  • How about that? Commented Jun 5, 2014 at 10:04
  • I have a excel data sheets to be insert. Commented Jun 5, 2014 at 10:07
  • @deceze, and also have sql server tables records to insert into postgreSQL table. There are many records to insert. Commented Jun 5, 2014 at 10:11
  • 1
    1) Excel sheets cannot be huge for PostgreSQL :) 2) Export data to CSV (or txt) 3) Use psql \copy command. Something like: \copy tabletest from mydata.csv with delimiter ';' (read docs for details) Commented Jun 5, 2014 at 10:24

1 Answer 1

2

Short answer: use the COPY command.

Details available in the Postgres 9.3 documentation

Note that the file should be available to the Postgres server machine because COPY is meant to be used mainly by DBAs.

And, if you have Excel, you'd have to export the data to CSV format first as Postgres cannot read Excel-formatted data directly.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.