用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)

 

posted @ 2015-02-03 12:46  ilxx1988  阅读(339)  评论(0编辑  收藏  举报