advice

From: Andrei Ivanov <andrei(dot)ivanov(at)ines(dot)ro>
To: pgsql-novice(at)postgresql(dot)org
Subject: advice
Date: 2003-10-22 19:58:12
Message-ID: Pine.LNX.4.58.0310222250520.31834@webdev.ines.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

  • Re: advice at 2003-10-22 20:27:25 from Josh Berkus
  • Re: advice at 2003-10-25 20:31:52 from Paul Ganainm

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2003-10-22 20:22:26 Re: Expressional Indexes
Previous Message Tom Lane 2003-10-22 19:44:58 Re: Expressional Indexes