How to invoke SELECT over DBLINK over DBLINK?

前端 未结 1 1257
天涯浪人
天涯浪人 2021-01-27 02:13

In Oracle 11G I can easily invoke:

SELECT * FROM TABLE@DB_LINK_NAME;

But how invoke SELECT over DB_LINK that is on another DB_LINK

相关标签:
1条回答
  • 2021-01-27 03:00

    First off, architecturally, I'd be pretty leery of any design that involved pulling data over multiple database links. I've seen it done when the eventual source is some ancient version of Oracle that the target database cannot connect to directly so an intermediate database running an intermediate version of Oracle was used. That is very rare in practice, though.

    From a performance perspective, this sort of approach is gravely problematic. There is, of course, the issue that the data is going to be sent over the network twice. But more to worryingly, you are taking a difficult problem, optimizing distributed SQL statements, and making it nearly intractable. You'd basically have to either guarantee that you would never query local data and remote data in the same query or you would have to live with the resulting performance if Oracle decides on a stupid query plan because the set of tools left to allow you to optimize this sort of query is minimal.

    That being said, the intermediate database would need to have synonyms or views that abstract away the database link. So

    On A:

    • create database link to B

    On B:

    • create database link to C
    • create synonym table for table@C

    On A, you can then

    SELECT *
      FROM table@B
    
    0 讨论(0)
提交回复
热议问题