These methods provide a framework for manipulating individual rows in existing tables. All operations expect that both existing and new data are presented in two compatible tbl objects.
If y
lives on a different data source than x
, it can be copied automatically
by setting copy = TRUE
, just like for dplyr::left_join()
.
On mutable backends like databases, these operations manipulate the
underlying storage.
In contrast to all other operations,
these operations may lead to irreversible changes to the underlying database.
Therefore, in-place updates must be requested explicitly with in_place = TRUE
.
By default, an informative message is given.
Unlike compute()
or copy_to()
, no new tables are created.
The sql_rows_*()
functions return the SQL used for the corresponding
rows_*()
function with in_place = FALSE
.
y
needs to be located on the same data source as x
.
# S3 method for tbl_dbi rows_insert(x, y, by = NULL, ..., in_place = NULL, copy = FALSE, check = NULL) # S3 method for tbl_dbi rows_update(x, y, by = NULL, ..., in_place = NULL, copy = FALSE, check = NULL) sql_rows_insert(x, y, ...) sql_rows_update(x, y, by, ...)
x | A pair of data frames or data frame extensions (e.g. a tibble).
|
---|---|
y | A pair of data frames or data frame extensions (e.g. a tibble).
|
by | An unnamed character vector giving the key columns. The key
values must uniquely identify each row (i.e. each combination of key
values occurs at most once), and the key columns must exist in both By default, we use the first column in |
... | Other parameters passed onto methods. |
in_place | Should When |
copy | If |
check | Set to Currently these checks are no-ops and need yet to be implemented. |
A tbl object of the same structure as x
.
If in_place = TRUE
, the underlying data is updated as a side effect,
and x
is returned, invisibly.
#> # Source: table<dbplyr_001> [?? x 3] #> # Database: sqlite 3.34.1 [:memory:] #> a b c #> <int> <chr> <dbl> #> 1 1 a 0.5 #> 2 2 b 1.5 #> 3 3 NA 2.5#> Error : `x` and `y` must share the same src, set `copy` = TRUE (may be slow).#>#> # Source: lazy query [?? x 3] #> # Database: sqlite 3.34.1 [:memory:] #> a b c #> <dbl> <chr> <dbl> #> 1 1 a 0.5 #> 2 2 b 1.5 #> 3 3 NA 2.5 #> 4 4 z NA#> # Source: lazy query [?? x 3] #> # Database: sqlite 3.34.1 [:memory:] #> a b c #> <int> <chr> <dbl> #> 1 1 a 0.5 #> 2 2 w 1.5 #> 3 3 w 2.5#> # Source: table<dbplyr_001> [?? x 3] #> # Database: sqlite 3.34.1 [:memory:] #> a b c #> <int> <chr> <dbl> #> 1 1 a 0.5 #> 2 2 b 1.5 #> 3 3 NA 2.5 #> 4 4 z NA#> # Source: table<dbplyr_001> [?? x 3] #> # Database: sqlite 3.34.1 [:memory:] #> a b c #> <int> <chr> <dbl> #> 1 1 a 0.5 #> 2 2 w 1.5 #> 3 3 w 2.5 #> 4 4 z NA