Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Update VS Delete/Update
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
![]() |
![]() |