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

Home -> Community -> Usenet -> c.d.o.server -> Re: Update VS Delete/Update

Re: Update VS Delete/Update

From: <bsc7080_at_mindspring.com>
Date: 2000/06/22
Message-ID: <q0m5lsk0v8avfuvqtvn9n5bigk782jenu0@4ax.com>#1/1

Inserts are always more costly than updates, unless you remove the indexes during inserting and reapply afterwards.

Here is one trick that works well:

UPDATE table
SET column = value
WHERE column = value;

IF SQL%ROWCOUNT = 0 THEN
 INSERT INTO table
 (column1,column2)
 VALUES
 (value1, value2);
END IF; COMMIT; The SQL%ROWCOUNT makes note of any records that were updated, if 0 then it simply inserts. No constraint violations, and you gain considerable speed.

On Tue, 20 Jun 2000 16:20:19 +0200, "Sybrand Bakker" <postbus_at_sybrandb.demon.nl> wrote:

>This is assuming you can't truncate it.
>
>Update will be faster.
>Also the second pair of commands will most likely force you to rebuild the
>indexes on this table.
>
>Hth,
>
>Sybrand Bakker, Oracle DBA
>
>
>
>"Brandon Duncan" <bduncan_at_pietechnet.com> wrote in message
>news:8inu72$s8n$1_at_bob.news.rcn.net...
>> Does anyone know which is faster :
>> "UPDATE tablex SET ....."
>>
>> or
>>
>> "DELTE FROM tablex"
>> "INSERT INTO tablex"
>>
>> Thanks,
>> Brandon
>>
>>
>>
>
Received on Thu Jun 22 2000 - 00:00:00 CDT

Original text of this message

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