sqlAppendTable()
generates a single SQL string that inserts a
data frame into an existing table. sqlAppendTableTemplate()
generates
a template suitable for use with dbBind()
.
The default methods are ANSI SQL 99 compliant.
These methods are mostly useful for backend implementers.
DBI:::methods_as_rd("sqlAppendTable")
sqlAppendTable(con, table, values, row.names = NA, ...)sqlAppendTableTemplate(
con,
table,
values,
row.names = NA,
prefix = "?",
...,
pattern = ""
)
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"')
A data frame. Factors will be converted to character vectors.
Character vectors will be escaped with dbQuoteString()
.
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
.
Other arguments used by individual methods.
Parameter prefix to use for placeholders.
Parameter pattern to use for placeholders:
""
: no pattern
"1"
: position
anything else: field name
The row.names
argument must be passed explicitly in order to avoid
a compatibility warning. The default will be changed in a later release.
sqlAppendTable(ANSI(), "iris", head(iris))
sqlAppendTable(ANSI(), "mtcars", head(mtcars))
sqlAppendTable(ANSI(), "mtcars", head(mtcars), row.names = FALSE)
sqlAppendTableTemplate(ANSI(), "iris", iris)
sqlAppendTableTemplate(ANSI(), "mtcars", mtcars)
sqlAppendTableTemplate(ANSI(), "mtcars", mtcars, row.names = FALSE)
Run the code above in your browser using DataLab