Differentiate between a row modification and add

oracle

Any recommendations into how one can figure out which rows were solely modified from an existing row (edit) and which one were solely inserted?

I know minus can extract any rows that were modified in any way (add/delete/edit), but right now I feel the only way to differentiate an "edit" among these 3 is to compare "hard values" shared between corresponding records and detect the column change…

Take below for example:

Table GarageBefore
__________________________
|Make |Color |VIN |Driver |  
|AUDI |GRAY  |650 |SMITH  |
|BMW  |SILV  |808 |JOHNS  |
|BMW  |GREE  |754 |CARRO  |
|CHEV |WHIT  |532 |JONES  |
|_________________________|

Table GarageAfter
__________________________
|Make |Color |VIN |Driver |  
|AUDI |GRAY  |650 |SMITH  |
|BMW  |SILV  |303 |JOHNS  |
|BMW  |GREE  |754 |CARRO  |
|BUIC |BLAC  |400 |JAMES  |
|CHEV |WHIT  |532 |JONES  |
|_________________________|


Desired Result

(Modified Existing Rows?)
|BMW  |SILV  |303 |JOHNS  |


(Added Rows?)
|BUIC |BLAC  |400 |JAMES  |

Best Answer

From the datasets you posted, no. You could add a column "modified" which contains a flag that tells you whether the row was modified or not. That column could be maintained via a trigger on the table, or, in my opinion better, you could encapsulate inserts/updates to that table in a stored procedure and have the procedure maintain that column.