db-link 表只能出现在顶层查询,或同源 dblink 的子查询中。出现在本地表的子查询中时,必须放在 relation 子查询中。 例如:如下语句会报语法错误,因为 db-link 出现在本地表的子查询中时, 必须用 relation 子查询包围。 select * from t1 where exists (select 1 from t2@gc_link as t2 where t2.id = t1.id); 该语句可以修改为如下形式,以保证符合语法规则: select * from t1 where exists (select 1 from (select 1 from t2@gc_link) as t2 where t2.id = t1.id);
db-link 表的子查询中,禁止出现本地表,非同源 dblink 表。 例如:select * from t1@gc_link where exists (select 1 from t2);是不允许的,因为 db-link 表 t1@gc_link 的子查询中出现了本地表 t2。可以改写为如下形式: select * from (select * from t1@gc_link) t where exists (select 1 from t2);