sql.insert {RPgSQL} | R Documentation |
sql.insert
is quite useful for appending data to database tables.
sql.insert(into, column.names, values, query)
into |
A character string with the table name |
column.names |
An optional list of column names |
values |
Data values, matrix or data frame to insert from |
query |
An SQL query |
The easiest way to use sql.insert
is to use the into
and
values
arguments. Enter the table name in the into
argument and set values
to a data frame. sql.insert
will
extract the column names from the data frame and update those
columns. See example below.
Timothy H. Keitt
if (db.connection.open()) { data(airquality) rpgsql.test.data <- airquality[1:5,] db.write.table(rpgsql.test.data, no.clobber=F) db.read.table('rpgsql.test.data') rpgsql.test.data <- airquality[6:10,] sql.insert(into='rpgsql.test.data', values=rpgsql.test.data) db.read.table('rpgsql.test.data') db.rm('rpgsql.test.data', ask=F) }