通过dblink连接查看远端表提示表或视图不存在

版权声明:本文为博主DbaH原创文章,允许转载,需要标明出处 https://blog.csdn.net/u011592350/article/details/78896346

通过dblink连接查看远端表提示表或视图不存在

1. A库:
  • user1用户下有source_table表
  • user1_interface用户下创建user1下source_table的同义词
    create synonym user1_interface.source_table_synoynm for user1.source_table;
2. B库:
  • 创建一个dblink使用user1_interface连接到A库user1_interface_dblink
  • 创建一个公共同义词
 create public synonym target_table_synonym for source_table@user1_interface_dblink;
3. 在B库查看该表时提示表或视图不存在
    select * from target_table_synonym;
    select * from source_table_synoynm@user1_interface_dblink;
4. 在A库查看有数据
    select * from user1_interface.source_table_synoynm;
    select * from user1.source_table;
5. 分析
5.1 分析可能是dblink问题
--下列查询未报错,排除dblink连接问题
 select * from dual@user1_interface_dblink;
5.2 分析可能是同义词失效
--A库同义词状态未失效
select * from dba_objects where object_name='SOURCE_TABLE_SYNOYNM';
--B库同义词状态未失效
select * from dba_objects where object_name='TARGET_TABLE_SYNOYNM';
5.3 发现是A库user1_interface用户对source_table 没有查询权限
6. 解决方法:

A库user1用户下授权

grant select on source_table to user1_interface;

猜你喜欢

转载自blog.csdn.net/u011592350/article/details/78896346
今日推荐