1. 连接数据
install.packages("RJDBC")
library(RJDBC)
ojdbcUrl <- "C:/Users/Administrator/Desktop/modelengine/ojdbc6_g.jar"
drv <- JDBC("oracle.jdbc.driver.OracleDriver", ojdbcUrl, identifier.quote = "`")
conn <- dbConnect(drv,"jdbc:oracle:thin:@10.60.45.44:1521:SID","sys as sysdba","password")
2.操作数据库
dbSendUpdate(conn,"create table users( id number,name varchar2(100) )");
dbRemoveTable(conn,"users")
dbSendUpdate(conn,"insert into users values(1,'张三')");
dbSendUpdate(conn,"update users set name='李四' where id=1")
b <- dbGetQuery(conn,"select * from users ");
3.关闭连接
dbDisconnect(conn)