title: Merging data between 2 separate Oracle databases
body: <p>I've got two separate, unconnected and unconnectable Oracle databases. I need to get information from one to the other as quickly and painlessly as possible.</p>
  
  <p>Typically what I've done up until now when in this situation is create a staging area for the data that needs to be imported (essentially a temporary table just for storing the data until I'm done merging). I copy <em>all</em> of the data that <em>might</em> be needed from the source to that staging area. Then I merge the data as I would if the two tables were connected, meaning of course that I can filter out whatever data I don't need at that time.</p>
  
  <p>Here's the problem in my current case. The source table is <em>extremely</em> large and entirely <em>un-indexed</em> (something over which I have no control, ugh). That means it takes <strong>forever</strong> to get the necessary data if I don't filter it in some way. In addition the destination table really only needs a relatively small subset of the data to do what it needs to do, maybe ten thousand or so distinct rows at a time. In this case I don't want to copy <em>all</em> of the data that <em>might</em> be needed. I just want to copy over the <em>exact</em> data that will be needed, or as close to that as possible.</p>
  
  <p><strong>tl:dr version</strong></p>
  
  <p><strong>Exactly how do I limit my select on the source table based on what I need in the destination table if they can't communicate with each other?</strong></p>
  
  <p>For example, I might select ID's for the data that is needed in the destination and build the query for the source table based on that. However, that might result in a query with many thousands of OR clauses in it:</p>
  
  <pre><code>SELECT x, y FROM z WHERE (ID = 1 OR ID = 2 ... OR ID = 10000 OR ID = 10001...)
  </code></pre>
  
  <p>Or something like that. Is there a better way of doing it?</p>