-
Notifications
You must be signed in to change notification settings - Fork 850
/
Copy pathdist_join.log
executable file
·103 lines (75 loc) · 2.91 KB
/
dist_join.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
SQL> @dist_join
SQL> -- Assumes we have two databases, r192 and r193, and that both are known
SQL> -- to the SQL Net listener
SQL>
SQL> connect system/oracle@localhost:1523/r192
Connected.
SQL>
SQL> drop user distuser cascade;
User dropped.
SQL>
SQL> grant connect,resource,ctxapp,unlimited tablespace,create database link to distuser identified by distuser;
Grant succeeded.
SQL>
SQL> connect system/oracle@localhost:1523/r193
Connected.
SQL>
SQL> drop user distuser cascade;
User dropped.
SQL>
SQL> grant connect,resource,ctxapp,unlimited tablespace,create database link to distuser identified by distuser;
Grant succeeded.
SQL>
SQL> connect distuser/distuser@localhost:1523/r192
Connected.
SQL> create table tab2 (id2 number primary key, text2 varchar2(200));
Table created.
SQL>
SQL> insert into tab2 values (1, 'hello world');
1 row created.
SQL>
SQL> create index tab2index on tab2(text2) indextype is ctxsys.context;
Index created.
SQL>
SQL> connect distuser/distuser@localhost:1523/r193
Connected.
SQL> create table tab3 (id3 number primary key, text3 varchar2(200));
Table created.
SQL>
SQL> insert into tab3 values (1, 'foo bar');
1 row created.
SQL>
SQL> create database link db2 connect to distuser identified by distuser using 'localhost:1523/r192';
Database link created.
SQL>
SQL> -- works
SQL> select * from tab2@db2 t2
2 where contains@db2 (text2, 'hello') > 0;
ID2
----------
TEXT2
--------------------------------------------------------------------------------
1
hello world
SQL>
SQL> -- works if we use a sub-query
SQL> select * from tab3 t3
2 where t3.id3 in
3 (select t2.id2 from tab2@db2 t2);
ID3
----------
TEXT3
--------------------------------------------------------------------------------
1
foo bar
SQL>
SQL> -- doesn't work if we use a join
SQL> select * from tab3 t3, tab2@db2 t2
2 where contains@db2 (text2, 'hello') > 0
3 and t3.id3 = t2.id2;
where contains@db2 (text2, 'hello') > 0
*
ERROR at line 2:
ORA-00949: illegal reference to remote database
SQL>
SQL> spool off