test Server:
SQL> show user
USER is "SYS"
SQL> create database link torhel2
2 connect to test identified by oracle
3 using 'rhel2';
Database link created.
rhel2 Server:
SQL> conn test/oracle
Connected.
SQL> select * from tab;
no rows selected
SQL> create table stu(id int,name varchar2(20));
Table created.
SQL> insert into stu values(1,'hrr');
1 row created.
SQL> insert into stu values(2,'xtt');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from stu;
ID NAME
---------- --------------------
1 hrr
2 xtt
SQL> select * from stu@rhel2;
select * from stu@rhel2
*
ERROR at line 1:
ORA-02019: connection description for remote database not found
该dblink不是public的,所以test用户无权访问
修改连接为public:
SQL> select owner# from sys.link$ where name like 'torhel2%';
no rows selected
SQL> select owner# from sys.link$ where name like 'TORHEL2%';
OWNER#
----------
0
SQL> update LINK$ set OWNER#=1 where name like 'TORHEL2%';
1 row updated.
SQL> commit;
Commit complete.
SQL> select owner# from sys.link$ where name like 'TORHEL2%';
OWNER#
----------
1
S
SQL> show user
USER is "SYS"
SQL> create database link torhel2
2 connect to test identified by oracle
3 using 'rhel2';
Database link created.
rhel2 Server:
SQL> conn test/oracle
Connected.
SQL> select * from tab;
no rows selected
SQL> create table stu(id int,name varchar2(20));
Table created.
SQL> insert into stu values(1,'hrr');
1 row created.
SQL> insert into stu values(2,'xtt');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from stu;
ID NAME
---------- --------------------
1 hrr
2 xtt
SQL> select * from stu@rhel2;
select * from stu@rhel2
*
ERROR at line 1:
ORA-02019: connection description for remote database not found
该dblink不是public的,所以test用户无权访问
修改连接为public:
SQL> select owner# from sys.link$ where name like 'torhel2%';
no rows selected
SQL> select owner# from sys.link$ where name like 'TORHEL2%';
OWNER#
----------
0
SQL> update LINK$ set OWNER#=1 where name like 'TORHEL2%';
1 row updated.
SQL> commit;
Commit complete.
SQL> select owner# from sys.link$ where name like 'TORHEL2%';
OWNER#
----------
1
S