title: Write R DataFrame to Teradata using RJDBC
body: <h2>We want to insert a dataframe into a table in teradata. so we connect to the database</h2>
  <pre><code>drv =     JDBC(&quot;com.teradata.jdbc.TeraDriver&quot;,&quot;C:\\Users\\~\\TeradataJDBCDDriver\\terajdb    c4.jar;C:\\Users\\~\\TeradataJDBCDDriver\\tdgssconfig.jar&quot;)  
  conn = dbConnect(drv,&quot;jdbc:teradata://###&quot;,&quot;username&quot;,&quot;password&quot;) 
  </code></pre>
  <p>So we created a dataframe:</p>
  <pre><code>column1&lt;-c(1,2,3,4)
  column2&lt;-c(&quot;bar1&quot;,&quot;bar2&quot;,&quot;bar3&quot;,&quot;bar4&quot;)
  df=data.frame(column1,column2)
  </code></pre>
  <p>And now we want to write the dataframe to a table in teradata. We tried three approaches</p>
  <p>first try where we define the table we want to create with its datatypes</p>
  <pre><code>dbWriteTable(conn,&quot;temp.test_table(a int,b varchar(100))&quot;, df)
  </code></pre>
  <p>Then the following error appears:</p>
  <pre><code>&quot;Error in .local(conn, statement, ...) : execute JDBC update query failed in     dbSendUpdate ([Teradata Database] [TeraJDBC 15.10.00.33] [Error 3706] [SQLState     42000] Syntax error: expected something between ')' and '('.)&quot;
  </code></pre>
  <p>The second approach we create a table first and try to append the dataframe second.</p>
  <pre><code>dbSendUpdate(conn,&quot;create table temp.test_table(a int,b varchar(100))&quot;)
  dbWriteTable(conn,&quot;temp.test_table&quot;, df,row.names=F,overwrite=F,append = T)
  </code></pre>
  <p>This leads to the following error:</p>
  <pre><code>Error in .local(conn, name, value, ...) : Cannot append to a non-existing table `temp.test_table'
  </code></pre>
  <p>When we check if the table exists using dbListTables() the table does exist however. (but not if we use dbExistTable())</p>
  <p>In the third try we try to overwrite instead of append the data.</p>
  <pre><code>dbWriteTable(conn,&quot;temp.test_table&quot;, df,row.names=F,overwrite=T,append = F)
  </code></pre>
  <p>Which leads to the following error:</p>
  <pre><code>Error in .local(conn, statement, ...) : execute JDBC update query failed in dbSendUpdate ([Teradata Database] [TeraJDBC 15.10.00.33] [Error 3803] [SQLState 42S01] Table 'test_table' already exists.)
  </code></pre>
  <p>now it states that the table already exists (that should be fine as, we want to overwrite it). But the table is not overwritten.</p>
  <p>all in all we're looking for a solution to write a dataframe from r into a teradata database.</p>
  <p>Anyone knows how to deal with this issue?</p>