title: Splitting large table into 2 dataframes via JDBC connection in RStudio
body: <p>Through R I connect to a remotely held database. The issue I have is my hardware isn't so great and the dataset contains tens of millions of rows with about 10 columns per table. When I run the below code, at the df step, I get a "Not enough RAM" error from R:</p>
  
  <pre><code>library(DatabaseConnector)
  conn &lt;- connect(connectionDetails)
  df &lt;- querySql(conn,"SELECT * FROM Table1")
  </code></pre>
  
  <p>What I thought about doing was splitting the tables into two parts any filter/analyse/combine as needed going forward. I <em>think</em> because I use the conn JDBC conection I have to use SQL syntax to make it work. With SQL, I start with the below code:</p>
  
  <pre><code>df &lt;- querySql(conn,"SELECT TOP 5000000 FROM Table1")
  </code></pre>
  
  <p>And then where I get stuck is how do I create a second dataframe starting with n - 5000000 rows and ending at the final row, retrieved from Table1. </p>
  
  <p>I'm open to suggestions but I think there are two potential answers to this question. The first is to work within the querySql to get it working. The second is to use an R function other than querySql (no idea what this would look like). I'm limited to R due to work environment.</p>