Re: most idiomatic way to "update or insert"?

From: Jerry Sievers <jerry(at)jerrysievers(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: most idiomatic way to "update or insert"?
Date: 2004-08-09 14:14:28
Message-ID: m3hdrco0u3.fsf@prod01.jerrysievers.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

gsstark(at)mit(dot)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/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jerry LeVan 2004-08-09 14:18:53 ANN: BiggerSQL-1.3.3
Previous Message Gaetano Mendola 2004-08-09 13:50:06 Re: PostgreSQL 8.0 Feature List?