Reputation: 1250
For example, if I want to create a table that stores the mtcars
data set in a remote database, I can do the following with DBI
:
dbWriteTable(database_connection, "MTCARS", mtcars)
I think behind the scenes, DBI
(or perhaps dbplyr
?) generates some SQL and send it to the database to complete the task. Then how can I get the SQL so that I can tweak it to better suit my use case?
Upvotes: 0
Views: 162
Reputation: 521093
The APIs from the DBI
(and other R SQL) package do not necessarily correspond to just one SQL operation. From the documentation for DBI, dbWriteTable
does the following:
Writes, overwrites or appends a data frame to a database table, optionally converting row names to a column and specifying SQL data types for fields.
That is, depending on how you call dbWriteTable
, using parameters such as append
and overwrite
, it may generate either an INSERT
, UPDATE
, or even an upsert.
Upvotes: 1