Convenience functions for reading/writing DBMS tables
# S4 method for class '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 class '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 class '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 class 'OdbcConnection'
dbAppendTable(
conn,
name,
value,
batch_rows = getOption("odbc.batch_rows", NA),
...,
row.names = NULL
)
# S4 method for class 'OdbcConnection'
sqlCreateTable(
con,
table,
fields,
row.names = NA,
temporary = FALSE,
...,
field.types = NULL
)An OdbcConnection object, produced by DBI::dbConnect().
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.
A data.frame to write to the database.
Allow overwriting the destination table. Cannot be
TRUE if append is also TRUE.
Allow appending to the destination table. Cannot be
TRUE if overwrite is also TRUE.
If TRUE, will generate a temporary table.
Either TRUE, FALSE, NA or a string.
If TRUE, always translate row names to a column called "row_names".
If FALSE, never translate row names. If NA, translate
rownames only if they're a character vector.
A string is equivalent to TRUE, but allows you to override the
default name.
For backward compatibility, NULL is equivalent to FALSE.
Additional field types used to override derived types.
The number of rows to retrieve. Defaults to NA, which
is set dynamically to the minimum of 1024 and the size of the input.
Depending on the database, driver, dataset and free memory, setting this
to a lower value may improve performance.
Other arguments used by individual methods.
A database connection.
The table name, passed on to dbQuoteIdentifier(). Options are:
a character string with the unquoted DBMS table name,
e.g. "table_name",
a call to Id() with components to the fully qualified table name,
e.g. Id(schema = "my_schema", table = "table_name")
a call to SQL() with the quoted and fully qualified table name
given verbatim, e.g. SQL('"my_schema"."table_name"')
Either a character vector or a data frame.
A named character vector: Names are column names, values are types.
Names are escaped with dbQuoteIdentifier().
Field types are unescaped.
A data frame: field types are generated using
dbDataType().
if (FALSE) { # \dontrun{
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)
} # }