用R把文档写回数据库

# 导入FMCG超敏感和敏感商品
dim_username_dept <- read.table(file = "~/dm/cluster/yihaodianbao",
                                    #header = TRUE,
                                    sep = "\t",
                                    #strip.white = TRUE,
                                    stringsAsFactors = FALSE)

str(dim_username_dept)

head(dim_username_dept)

names(dim_username_dept) <- c("USER_NAME", "FULL_NAME", "EMAIL", "DEPT")

## Write Databases Tables
library("DBI")
library("ROracle")

drv <- dbDriver("Oracle")
con <- dbConnect(drv,"tangjingxiao1","cathy,123",dbname = "10.0.1.226:1521/edwstd01")


# 回写到数据库的字段名称,一定要大写,否则在Oracle里识别不出来
names(dim_username_dept) <- toupper(names(dim_username_dept))

# 回写到数据库的表名,一定要大写
dbWriteTable(con, toupper("dim_username_dept"), dim_username_dept, row.names = FALSE)
dbCommit(con)
dbDisconnect(con)

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。