oracle diff: how to compare two tables?

后端 未结 12 1946
忘了有多久
忘了有多久 2021-01-31 03:22

Suppose I have two tables, t1 and t2 which are identical in layout but which may contain different data.

What\'s the best way to diff these two tables?

12条回答
  •  [愿得一人]
    2021-01-31 03:54

    For this kind of question I think you have to be very specific about what you are looking for, as there are many ways of interpreting it and many different approaches. Some approaches are going to be too big a hammer if your question does not warrant it.

    At the simplest level, there is "Is the table data exactly the same or not?", which you might attempt to answer with a simple count comparison before moving on to anything more complex.

    At the other end of the scale there is "show me the rows from each table for which there is not an equivalent row in the other table" or "show me where rows have the same identifying key but different data values".

    If you actually want to sync Table A with Table B then that might be relatively straightforward, using a MERGE command.

提交回复
热议问题