Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Oracle update columns when the data values are the same?

If I have a column called NAME and it has a value of "CLARK" and I run an update statement

update table1 set name = 'CLARK';

Does Oracle actually update the column or does it ignore the update command since the values are the same?

I found this question (Oracle, how update statement works) and the first answer implies that an update occurs even if the values are equal. I also tried it in SQL Developer and it ran but I don't know if an update truly occurred.

Thanks in advance.

like image 805
BigFish Avatar asked Oct 24 '25 02:10

BigFish


2 Answers

Yes, Oracle does update the column even if it the same.

In a really simple example, this makes no difference. But consider the following:-

  • When a record is updated, a lock is obtained on that record for the updating session,
  • When a record is updated, triggers on the table would fire

This aspects of the update show that the column is actually updated.

Of course, perhaps there are some optimisations when the value is the same, but these are not visible to you as a user of Oracle.

like image 188
WW. Avatar answered Oct 25 '25 20:10

WW.


Yes, all row are updated and all triggers fired, even if the actual values doesn't change.

like image 22
dbra Avatar answered Oct 25 '25 22:10

dbra