title: How do I merge two similar database-schema in PL/SQL?
body: <p>The database-schema (Source and target) are very large (each has over 350 tables). I have got the task to somehow merge these two tables into one. The data itself (whats in the tables) has to be migrated. I have to be careful that there are no double entries for primary keys before or while merging the schemata. Has anybody ever done that already and would be able to provide me his solution or could anyone help me get a approach to the task? My approaches all failed and my advisor just tells me to get help online :/</p>
  <p>To my approach:
  I have tried using the &quot;all_constraints&quot; table to get all pks from my db.</p>
  <pre><code>SELECT cols.table_name, cols.column_name, cols.position, cons.status, cons.owner
  FROM all_constraints cons, all_cons_columns cols
  WHERE cols.owner = 'DB'
  AND cons.constraint_type = 'P'  
  AND cons.constraint_name = cols.constraint_name
  AND cons.owner = cols.owner
  ORDER BY cols.table_name, cols.position;
  </code></pre>
  <p>I also &quot;know&quot; that there has to be a sequence for the primary keys to add values to it:</p>
  <pre><code>CREATE SEQUENCE seq_pk_addition
  MINVALUE 1
  MAXVALUE 99999999999999999999
  START WITH 1
  INCREMENT BY 1
  CACHE 20;
  </code></pre>
  <p>Because I am a noob if it comes to pl/sql (or sql in general)
  So how/what I should do next? :/</p>
  <blockquote>
  <p>Here is a link for an ERD of the database:  <a href="https://ufile.io/9tdoj" rel="nofollow noreferrer">https://ufile.io/9tdoj</a></p>
  <p>virus scan: <a href="https://www.virustotal.com/#/file/dbe5f418115e50313a2268fb33a924cc8cb57a43bc85b3bbf5f6a571b184627e/detection" rel="nofollow noreferrer">https://www.virustotal.com/#/file/dbe5f418115e50313a2268fb33a924cc8cb57a43bc85b3bbf5f6a571b184627e/detection</a></p>
  </blockquote>