Add a variable to a table in MonetDBLite

47 Views Asked by At

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?

1

There are 1 best solutions below

2
Hannes Mühleisen On BEST ANSWER

Try

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