Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: If it Exists... Update. If it DNE... insert.

Re: If it Exists... Update. If it DNE... insert.

From: Walnut <walnut_at_froggy.com.au>
Date: Fri, 20 Jul 2001 21:12:15 +1000
Message-ID: <11cblt4olv8oqk629g9nkm8chfellm2uvg@4ax.com>

If the table/data has a primary key, why not just attempt an UPDATE and check if the update failed. If it did fail, INSERT it.

On Mon, 16 Jul 2001 09:02:36 +0200, Ruud de Koter <ruud_dekoter_at_hp.com> wrote:

> Hi Muirwa (?),
>
> muirwa wrote:
> >
> > I have a relatively simple question, that I can't find an explicit
> > answer to. So, I thought I would ask here.
> >
> > I am using JDBC with MySql and I have one flat and relatively simple
> > table. However, I will have to perform a large number of Inserts and
> > update. I am concerned with the load it can handle, and its
> > efficiency. My questions is, what is the 'best' way to go about the
> > following:
> >
> > 1. Given a Record, check to see if it exists in the table (SELECT).
> >
> > 1.1 If it exists, UPDATE record in the table.
> > 1.2 If it doesn't exist, INSERT record into table.
> >
> > However, given the simple steps above... For every one insert, there
> > are probably 100,000 updates. So, essentially there are 99,999 wasted
> > "SELECT" queries. But, as far as I can see it, it must be done in
> > order to determine whether to INSERT or UPDATE.
Received on Fri Jul 20 2001 - 06:12:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US