DBI-tables | R Documentation |
Convenience functions for reading/writing DBMS tables
## S4 method for signature 'OdbcConnection,character,data.frame'
dbWriteTable(
conn,
name,
value,
overwrite = FALSE,
append = FALSE,
temporary = FALSE,
row.names = NULL,
field.types = NULL,
batch_rows = getOption("odbc.batch_rows", NA),
...
)
## S4 method for signature 'OdbcConnection,Id,data.frame'
dbWriteTable(
conn,
name,
value,
overwrite = FALSE,
append = FALSE,
temporary = FALSE,
row.names = NULL,
field.types = NULL,
batch_rows = getOption("odbc.batch_rows", NA),
...
)
## S4 method for signature 'OdbcConnection,SQL,data.frame'
dbWriteTable(
conn,
name,
value,
overwrite = FALSE,
append = FALSE,
temporary = FALSE,
row.names = NULL,
field.types = NULL,
batch_rows = getOption("odbc.batch_rows", NA),
...
)
## S4 method for signature 'OdbcConnection'
dbAppendTable(
conn,
name,
value,
batch_rows = getOption("odbc.batch_rows", NA),
...,
row.names = NULL
)
## S4 method for signature 'OdbcConnection'
sqlCreateTable(
con,
table,
fields,
row.names = NA,
temporary = FALSE,
...,
field.types = NULL
)
conn |
a |
name |
a character string specifying a table name. Names will be automatically quoted so you can use any sequence of characters, not just any valid bare table name. |
value |
A data.frame to write to the database. |
overwrite |
Allow overwriting the destination table. Cannot be
|
append |
Allow appending to the destination table. Cannot be
|
temporary |
If |
row.names |
Either If A string is equivalent to For backward compatibility, |
field.types |
Additional field types used to override derived types. |
batch_rows |
The number of rows to retrieve. Defaults to |
... |
Other arguments used by individual methods. |
con |
A database connection. |
table |
The table name, passed on to
|
fields |
Either a character vector or a data frame. A named character vector: Names are column names, values are types.
Names are escaped with A data frame: field types are generated using
|
## Not run:
library(DBI)
con <- dbConnect(odbc::odbc())
dbListTables(con)
dbWriteTable(con, "mtcars", mtcars, temporary = TRUE)
dbReadTable(con, "mtcars")
dbListTables(con)
dbExistsTable(con, "mtcars")
# A zero row data frame just creates a table definition.
dbWriteTable(con, "mtcars2", mtcars[0, ], temporary = TRUE)
dbReadTable(con, "mtcars2")
dbDisconnect(con)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.