我一直在尝试找出如何将数据帧写入Teradata服务器上的易失性表中。我试图遵循this example,但运气不佳。
这是我的尝试:
pass = getPass(msg = "Network Password:")
edv = odbcConnect(dsn = "", uid = "", pwd = pass)
rm(pass)
# So I believe we'll first have to create a table:
quer1 = paste("CREATE VOLATILE TABLE testdat",
"(op_sys INT, enter_final_icu VARCHAR(20), mrn VARCHAR(8))",
"UNIQUE PRIMARY INDEX(op_sys)",
"ON COMMIT PRESERVE ROWS;")
sqlQuery(edv, quer1)
# This returns a zero row table, so far so good:
quer2 = "select top 10 * from testdat"
sqlQuery(edv, quer2)
# See if we can save the data:
columnTypes <- list(op_sys = "INT",
enter_final_icu = "VARCHAR(20)",
mrn = "VARCHAR(8)")
# pop is a data.frame with 3 the same 3 columns as in the definition of testdat
sqlSave(channel = edv,
dat = pop,
tablename = 'testdat',
append = TRUE,
rownames = FALSE,
varTypes = columnTypes)
sqlUpdate(channel = edv,
dat = pop,
tablename = 'testdat')
sqlSave
语句告诉我“表testdat已存在”,这是我想做的。我以为update = TRUE
可以让我向表中添加数据...
sqlUpdate
语句告诉我“ testdat:未找到表”,考虑到我能够查询它,这很奇怪。
任何建议将不胜感激,谢谢!