Learn R Programming

odbc (version 1.0.0)

odbc-tables: Convenience functions for reading/writing DBMS tables

Description

Convenience functions for reading/writing DBMS tables

Usage

"dbWriteTable"(conn, name, value, overwrite = FALSE, append = FALSE, temporary = FALSE, ...)
"sqlData"(con, value, row.names = NA, ...)
"dbReadTable"(conn, name, ...)

Arguments

conn
a OdbcConnection object, produced by dbConnect
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 TRUE if append is also TRUE.
append
Allow appending to the destination table. Cannot be TRUE if overwrite is also TRUE.
temporary
If TRUE, will generate a temporary table statement.
...
Other arguments used by individual methods.
con
A database connection.
row.names
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.

Examples

Run this code
## 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)

Run the code above in your browser using DataLab