Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Oracle R Enterprise Tips

More than 5 years have passed since last update.

ORE 使用時の備忘録です。
ORE のインストール手順はこちらから。

DB 接続

> library(ORE)
> Sys.setenv(TZ = "JST")
> ore.connect(user="ORE", service_name="orcl", host="192.168.56.101", password="ore", port=1521, all=TRUE)
> ore.is.connected()

ORE ユーザのオブジェクト参照

user=ORE で接続したユーザのオブジェクトを参照可能です。

> ore.ls()
[1] "EMP" "T1" 
> EMP
   EMPNO  ENAME       JOB  MGR   HIREDATE  SAL COMM DEPTNO
1   7369  SMITH     CLERK 7902 1980-12-17  800   NA     20
2   7499  ALLEN  SALESMAN 7698 1981-02-20 1600  300     30
3   7521   WARD  SALESMAN 7698 1981-02-22 1250  500     30
4   7566  JONES   MANAGER 7839 1981-04-02 2975   NA     20
5   7654 MARTIN  SALESMAN 7698 1981-09-28 1250 1400     30
6   7698  BLAKE   MANAGER 7839 1981-05-01 2850   NA     30
7   7782  CLARK   MANAGER 7839 1981-06-09 2450   NA     10
8   7788  SCOTT   ANALYST 7566 1987-04-19 3000   NA     20
9   7839   KING PRESIDENT   NA 1981-11-17 5000   NA     10
10  7844 TURNER  SALESMAN 7698 1981-09-08 1500    0     30
11  7876  ADAMS     CLERK 7788 1987-05-23 1100   NA     20
12  7900  JAMES     CLERK 7698 1981-12-03  950   NA     30
13  7902   FORD   ANALYST 7566 1981-12-03 3000   NA     20
14  7934 MILLER     CLERK 7782 1982-01-23 1300   NA     10
Warning message:
ORE object has no unique key - using random order 
> T1
[1] COL1
<0 rows> (or 0-length row.names)
Warning message:
ORE object has no unique key - using random order 
>

念のため、DB 側で作成されているオブジェクトを確認してみます。

SQL> conn ore/ore
Connected.
SQL> show user
USER is "ORE"
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
EMP                            TABLE
T1                             TABLE

SQL>

任意のスキーマのオブジェクト参照

一度 sync コマンドで対象のオブジェクトをマッピングしなければいけないようです。

> ore.sync(schema="SYS", table="DBA_HIST_ACTIVE_SESS_HISTORY")
> ore.exists(schema="SYS", name="DBA_HIST_ACTIVE_SESS_HISTORY")
[1] TRUE
> ore.get(schema="SYS", name="DBA_HIST_ACTIVE_SESS_HISTORY")
ryo0123
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away