Windows下ROracle安装及使用,windowsroracle安装


ROracle简介:

ROracle是R连接访问Oracle数据库一个DBI(Oracledatabase interface)接口,这是一个基于OCI的一个DBI兼容的Oracle驱动程序.

详细说明见:http://cran.r-project.org/web/packages/ROracle/ROracle.pdf

 

在Linux下安装ROracle比较简单,只需要用install.packages("ROracle")即可,在windows下要通过源码安装。

 

安装源文件下载地址:

http://cran.rstudio.com/src/contrib/ROracle_1.1-11.tar.gz

 

Win7中R安装ROracle方法:

 

设置环境变量:

setOCI_LIB64=E:\app\licz\product\11.2.0\dbhome_1\BIN

setOCI_INC=E:\app\licz\product\11.2.0\dbhome_1\OCI\include

set PATH=C:\ProgramFiles\R\R-3.1.1\bin\x64

 

注意:

如果安装的的R 64bit版本,那么oracle client也要是64位版本

 

安装步骤:

打开R

C:\Users\licz>R

>install.packages("ROracle",type = "source")

trying URL'http://cran.rstudio.com/src/contrib/ROracle_1.1-11.tar.gz'

Content type'application/x-gzip' length 226769 bytes (221 Kb)

opened URL

downloaded 221 Kb

 

* installing *source* package'ROracle' ...

** 成功将'ROracle'程序包解包并MD5和检查

cygwin warning:

  MS-DOS style path detected:E:\app\licz\product\11.2.0\dbhome_2\BIN

  Preferred POSIX equivalent is:/cygdrive/e/app/licz/product/11.2.0/dbhome_2/BIN

  CYGWIN environment variable option"nodosfilewarning" turns off this warning.

  Consult the user's guide for more detailsabout POSIX paths:

   http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

Oracle Client Shared Library64-bit - 11.2.0.3.0 Operating in ORACLE_HOME environment.

found Oracle ClientE:\app\licz\product\11.2.0\dbhome_2\BIN

found Oracle Client includeE:\app\licz\product\11.2.0\dbhome_2\OCI\include

copying fromE:\app\licz\product\11.2.0\dbhome_2\OCI\include

** libs

警告: this package has a non-empty 'configure.win' file,

so building only the mainarchitecture

 

cygwin warning:

  MS-DOS style path detected:C:/PROGRA~1/R/R-31~1.1/etc/x64/Makeconf

  Preferred POSIX equivalent is:/cygdrive/c/PROGRA~1/R/R-31~1.1/etc/x64/Makeconf

  CYGWIN environment variable option"nodosfilewarning" turns off this warning.

  Consult the user's guide for more detailsabout POSIX paths:

   http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

gcc -m64-I"C:/PROGRA~1/R/R-31~1.1/include" -DNDEBUG -I./oci   -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall -std=gnu99 -mtune=core2 -c rodbi.c -o rodbi.o

gcc -m64-I"C:/PROGRA~1/R/R-31~1.1/include" -DNDEBUG -I./oci   -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall -std=gnu99 -mtune=core2 -c rooci.c -o rooci.o

In file included fromC:/PROGRA~1/R/R-31~1.1/include/R.h:50:0,

                 from rodbi.h:38,

                 from rooci.c:64:

C:/PROGRA~1/R/R-31~1.1/include/R_ext/RS.h:45:0:warning: "ERROR" redefined [enabled by default]

c:\rtools\gcc-4.6.3\bin\../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/include/wingdi.h:70:0:note: this is the location of the previous definition

gcc -m64 -shared -s-static-libgcc -o ROracle.dll tmp.def rodbi.o rooci.o E:\app\licz\product\11.2.0\dbhome_2\BIN/oci.dll-Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64-Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-31~1.1/bin/x64-lR

installing to C:/ProgramFiles/R/R-3.1.1/library/ROracle/libs/x64

** R

** inst

** preparing package for lazyloading

Creating a generic function for'summary' from package 'base' in package 'ROracle'

** help

*** installing help indices

** building package indices

** testing if installed packagecan be loaded

* DONE (ROracle)

 

The downloaded source packagesare in

         ‘C:\Users\licz\AppData\Local\Temp\RtmpAjzrhP\downloaded_packages’

 

ROracle包使用:

>library(ROracle)

载入需要的程辑包:DBI

 

# 连接本地Oracle数据库

> con <- dbConnect(drv,username = "scott", password = "tiger")

> rs <- dbSendQuery(con,"select * from emp where deptno = 10")

> data <- fetch(rs)

> data

  EMPNO ENAME       JOB  MGR  HIREDATE  SAL COMM DEPTNO

1  7782 CLARK   MANAGER 7839 1981-06-092450   NA     10

2  7839  KING PRESIDENT   NA 1981-11-175000   NA    10

3  7934 MILLER     CLERK 7782 1982-01-23 1300   NA    10

> dim(data)

[1] 3 8

 

# 连接远程Oracle数据库

> drv <-dbDriver("Oracle")

> connect.string <-"(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.5.195)(PORT =1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = cwdb)))"

> con <- dbConnect(drv,username = "scott", password = "tiger",

+ dbname = connect.string)

> rs <- dbSendQuery(con,"select * from emp where deptno = 10")

> data <- fetch(rs)

> data

  EMPNO ENAME       JOB  MGR  HIREDATE  SAL COMM DEPTNO

1  7782 CLARK   MANAGER 7839 1981-06-092450   NA     10

2  7839  KING PRESIDENT   NA 1981-11-175000   NA     10

3  7934 MILLER     CLERK 7782 1982-01-23 1300   NA    10

> dim(data)

[1] 3 8


windows下怎使用oracle,必须用客户端?还有使用步骤是什

windows下安装oracle

wenku.baidu.com/...b.html

windows下oracle的使用

wenku.baidu.com/...d.html
 

windows下刚安装的oracle 11 R1 登陆SQL/PLUS时出错 ERROR: ORA-12560: TNS: 协议适配器错误?

先检查服务是否已启动:
Oracle<ORACLE_HOME_NAME>TNSListener的状态是否为“已启动”。
OracleServiceSID的状态是否为“已启动”。
OracleCSService的状态是否为“已启动”。
如果否,则启动该服务。如果是,则使用net manager查看网络配置(概要文件,服务名称和监听程序)是否正确。
如果配置无误,则在命令行方式下,输入连接命令。
其格式是:conn username/password@connect_identifier 。其中,
username:用户名 password:口令 connect_identifier:连接描述符
如果没有指定连接描述符,则连接到系统环境变量ORACLE_SID所指定的数据库。
如果没有设定ORACLE_SID,则可设置操作系统环境变量。方法是:
在“运行”中输入CMD,再输入 SET ORACLE_SID=orcl即可。
(如果你采用的是默认安装,安装过程中没有修改过数据库名称DB_NAME和数据库实例SID,则连接描述符通常为orcl。)
如果你的机器上安装过两个或两个以上数据库,则必须在命令中加上@连接描述符。
(2)若在图形界面方式下,则需在主机字符串(Host string)中指明连接描述符。
有问题再联系。祝一切顺利。
 

相关内容

    暂无相关文章