Skip to contents

Add missing columns to a table

Usage

add_missing_columns(con, table, columns)

Arguments

con

A DBI connection with write access.

table

Character. Name of an existing table.

columns

Named character vector c(column = "TYPE").

Value

The names of the columns added, invisibly.

Examples

con <- db_connect(tempfile(fileext = ".duckdb"))
#> duckdb is storing downloaded extensions and secrets under ~/.duckdb:
#> ℹ /home/agoutsmedt/.duckdb
#> This persists across sessions and is shared with the DuckDB CLI and other clients.
#> ℹ Run duckdb(shared_home = FALSE) to use a temporary directory instead.
#> ℹ See ?duckdb_storage for details and alternatives.
DBI::dbWriteTable(con, "document", data.frame(doc_id = "a:1"))
add_missing_columns(con, "document", c(year = "INTEGER", doc_id = "VARCHAR"))
#> ℹ document: added column year.
DBI::dbListFields(con, "document")
#> [1] "doc_id" "year"  
db_disconnect(con)