Re: most idiomatic way to "update or insert"? - Mailing list pgsql-general

From Jerry Sievers
Subject Re: most idiomatic way to "update or insert"?
Date
Msg-id m3hdrco0u3.fsf@prod01.jerrysievers.com
Whole thread Raw
In response to Re: most idiomatic way to "update or insert"?  ("Peter Darley" <pdarley@kinesis-cem.com>)
List pgsql-general
gsstark@mit.edu (Greg Stark) writes:
> This happens most often when I have a list of items and have a UI that allows
> the user to edit the entire list and commit a whole new list in one action.
> It's much easier to simply delete the old list and insert the entire new list
> in a single query than to try to figure out which rows to delete and which to
> insert.

Right, but this is going to quit working for you as soon as foreign
key references are involved.  For that matter, other types of
dependent objects will prevent this as well.

In other words, when your relational database actually becomes
relational  :-)

I too was in the habit of the delete/insert as a lazy mans update on
simple schemad DBs.

HTH

--
-------------------------------------------------------------------------------
Jerry Sievers   305 854-3001 (home)     WWW ECommerce Consultant
                305 321-1144 (mobile    http://www.JerrySievers.com/

pgsql-general by date:

Previous
From: ree
Date:
Subject: How Two JOINS from one table
Next
From: Gaetano Mendola
Date:
Subject: Re: Copy data from one table to another, where some records might