Table old vs new value on merge? Say I have a table with two columns, new, old.
Whenever a row is inserte for the first time, new will be set and old should default to null.
Whenever a row is updated, the new should become the new value, and old should become the replaced value of new.
How to do this using Oracle?
Like this, I presume.
SQL&gt; create table test (id number, old number, new number);

Table created.

SQL&gt; insert into test (id, new) values (1, 100);

1 row created.

SQL&gt; select * from test;

        ID        OLD        NEW
---------- ---------- ----------
         1                   100

SQL&gt; update test set old = new,
  2                  new = 200
  3    where id = 1;

1 row updated.

SQL&gt; select * from test;

        ID        OLD        NEW
---------- ---------- ----------
         1        100        200

SQL&gt;