title: Migration script for splitting rows between table of different schemas
body: <p>I have a table which contains the following columns and I am trying to split it as follows. How do I write a migration script for the following transformation in Oracle</p>
  
  <p>source:</p>
  
  <pre><code>create table abc (id pk, col1, col2, col3, col4, col5, col6)
  </code></pre>
  
  <p>targets:</p>
  
  <pre><code>create table def (id pk, col1, col2)
  create table ghi (id pk, def_id fk, value)
  </code></pre>
  
  <p>Given this starting point ...</p>
  
  <pre><code>insert into table abc values (1, 1, 2, 3, 4, 5, 6)
  insert into table abc values (2, 7, 8, 9, 10, 11, 12)
  </code></pre>
  
  <p>... the post translation the data gets mapped as follows</p>
  
  <pre><code>def contains (1, 1, 2)
  ghi contains (1, 1, 3)
  ghi contains (2, 1, 4)
  ghi contains (3, 1, 5)
  ghi contains (4, 1, 6)
  
  def contains (2, 7, 8)
  ghi contains (5, 2, 9)
  ghi contains (6, 2, 10)
  ghi contains (7, 2, 11)
  ghi contains (8, 2, 12)
  </code></pre>
  
  <p>The most important restriction is that I want to generate rows in <code>ghi</code> only if the corresponding column values in <code>abc</code> are <code>not null</code></p>