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. New code should prefer dbCreateTable() and dbAppendTable().

Methods in other packages

  • DatabaseConnector::dbWriteTable("DatabaseConnectorConnection", "character", "data.frame")

# S4 method for DatabaseConnectorConnection,character,data.frame
dbWriteTable(
  conn,
  name,
  value,
  overwrite = FALSE,
  append = FALSE,
  temporary = FALSE,
  oracleTempSchema = NULL,
  ...
)

Arguments

conn

A DBIConnection object, as returned by dbConnect().

name

A character string specifying the unquoted DBMS table name, or the result of a call to dbQuoteIdentifier().

value

a data.frame (or coercible to data.frame).

overwrite

Overwrite an existing table (if exists)?

append

Append to existing table?

temporary

Should the table created as a temp table?

oracleTempSchema

Specifically for Oracle, a schema with write privileges where temp tables can be created.

...

Other parameters passed on to methods.

Value

dbWriteTable() returns TRUE, invisibly. If the table exists, and both append and overwrite arguments are unset, or append = TRUE and the data frame with the new data has different column names, an error is raised; the remote table remains unchanged.

An error is raised when calling this method for a closed or invalid connection. An error is also raised if name cannot be processed with dbQuoteIdentifier() or if this results in a non-scalar. Invalid values for the additional arguments row.names, overwrite, append, field.types, and temporary (non-scalars, unsupported data types, NA, incompatible values, duplicate or missing names, incompatible columns) also raise an error.

See also