title: Differences in column values between 2 two identical table structures
body: <p>Oracle Database: I have a table which is kept in sync with data from an external system. Every 15 minutes, we get a feed of any changes to this master table. We can store this feed of modified records in a staging table. We need to find the columns that have changed between the master and the staging table and record these differences for a subsequent processing.</p>
  
  <p>Simple example:</p>
  
  <pre><code>CREATE TABLE Master
  (
   Id int NOT NULL,
   LastName varchar(255) NOT NULL,
   FirstName varchar(255),
   CONSTRAINT pk_ID PRIMARY KEY (Id)
  );
  </code></pre>
  
  <p>Now, I have a Stage table that has exactly the same structure. In this simple example, I can do a diff between the Master and Stage like so:</p>
  
  <pre><code>  select decode( a.FirstName, b.FirstName, 0, 1 ) firstname_changed,
    decode( a.LastName, b.LastName, 0, 1 ) lastname_changed
    from Stage a, Master b
    where a.Id = b.Id;
  </code></pre>
  
  <p>Now the problem is that the master table contains 145 columns. I was wondering if there was a better way to do this.</p>