Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9070369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:40:21+00:00 2026-06-16T17:40:21+00:00

I have to dump large amount of data from file to a table PostgreSQL.

  • 0

I have to dump large amount of data from file to a table PostgreSQL. I know it does not support ‘Ignore’ ‘replace’ etc as done in MySql. Almost all posts regarding this in the web suggested the same thing like dumping the data to a temp table and then do a ‘insert … select … where not exists…’.

This will not help in one case, where the file data itself contained duplicate primary keys.
Any body have an idea on how to handle this in PostgreSQL?

P.S. I am doing this from a java program, if it helps

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:40:22+00:00Added an answer on June 16, 2026 at 5:40 pm

    Use the same approach as you described, but DELETE (or group, or modify …) duplicate PK in the temp table before loading to the main table.

    Something like:

    CREATE TEMP TABLE tmp_table 
    ON COMMIT DROP
    AS
    SELECT * 
    FROM main_table
    WITH NO DATA;
    
    COPY tmp_table FROM 'full/file/name/here';
    
    INSERT INTO main_table
    SELECT DISTINCT ON (PK_field) *
    FROM tmp_table
    ORDER BY (some_fields)
    

    Details: CREATE TABLE AS, COPY, DISTINCT ON

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simulation in which I need to dump large amount of data,
I have a large database dump.sql file I am importing from the command line
I have a large sql dump file ... with multiple CREATE TABLE and INSERT
Have some issues with passing large amount of data (3 MB) from uboot to
I have a large data coming from a csv file which looks something like
I have an application that reads from large amount of MSMQ queues(about 10000 at
The application we have takes large amount of data most of which is called
I have a large database, and I want to dump the data after custom
I have a table with large amounts of BLOB data in a column. I
I have a large file from 2007 containing a backup (as a SQL Script)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.