advice - Mailing list pgsql-novice

From Andrei Ivanov
Subject advice
Date
Msg-id Pine.LNX.4.58.0310222250520.31834@webdev.ines.ro
Whole thread Raw
Responses Re: advice  (Josh Berkus <josh@agliodbs.com>)
List pgsql-novice
Hello,
I have 2 tables with identical schemas.
What I have to do is insert in the 1st table all the rows from the
2nd table that don't exist in the 1st.

I'm planning to something like
INSERT INTO first_table
  SELECT * FROM second_table s WHERE
     NOT EXISTS (SELECT 1 FROM first_table WHERE id = s.id)

but I'm not sure this is the best way to do it...

Would anyone care to suggest a better query to do this ?

Thank you.


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: index usage
Next
From: Josh Berkus
Date:
Subject: Re: advice