Generate a INSERT statement, optionally execute the statement if con is not NULL.
insert_values(
x = NULL,
schema = NULL,
table,
returning = NULL,
quote_text = TRUE,
cast = TRUE,
types = NULL,
batch_size = 1000,
con = NULL,
table_is_temporary = FALSE,
retain_insert_order = FALSE,
n_cores = 1,
connect_db_name = NULL,
dialect = "T-SQL"
)
A string, the INSERT statement; or the results retrieved by DBI::dbGetQuery after executing the statement.
A list, data.frame or data.table, names must match the column names of the destination SQL table.
A string, the schema name of the destination SQL table.
A string, the table name of the destination SQL table.
A vector of character strings specifying the SQL column names to be returned by the INSERT statement.
TRUE/FALSE, if TRUE, calls quoteText() to add single quotes around character strings.
TRUE/FALSE, if TRUE, will add SQL to cast the data to be inserted to the specified type.
A vector of types to use for casting columns. If blank, will look at meta data about table to decide types.
Integer, the maximum number of records to submit in one statement.
A database connection that can be passed to DBI::dbSendQuery/DBI::dbGetQuery.
TRUE/FALSE, if TRUE, prevents parallel processing.
TRUE/FALSE, if TRUE, prevents parallel processing.
A integer, the number of cores to use for parallel forking (passed to parallel::mclapply as mc.cores).
The name of the database to pass to connect() when inserting in parallel.
A string, "T-SQL" or "Postgresql".
insert_values(
x = list(col1 = c("a", "b", "c"), col2 = c(1, 2, 3)),
schema = "test",
table = "table1",
types = c("VARCHAR(12)", "INT")
)
Run the code above in your browser using DataLab