rdplyrr-dbidbplyrmonetdblite

Add a variable to a table in MonetDBLite


Here is mtcars data in the MonetDBLite database file.

library(MonetDBLite)
library(tidyverse)
library(DBI)

dbdir <- getwd()
con <- dbConnect(MonetDBLite::MonetDBLite(), dbdir)

dbWriteTable(conn = con, name = "mtcars_1", value = mtcars)

data_mt <- con %>% tbl("mtcars_1")

dbSendQuery(con, "ALTER TABLE mtcars_1 ADD COLUMN new=2")

How should I add a column/variable "new" to the table mtcars_1 in the MonetDBLite?


Solution

  • Try

    dbSendQuery(con, "ALTER TABLE mtcars_1 ADD COLUMN new_col INTEGER DEFAULT 2")