Query two tables from different schema

前端 未结 5 1923
醉话见心
醉话见心 2020-12-17 19:30

I have two different schemas in Oracle (say S1, S2) and two tables in those schemas (say S1.Table1, S2.Table2). I want to query these two tables from schema S1.

Both

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 19:48

    DB Links are pretty much the name of the game here. If you can't get one created on your own, then check if there are any public DB links that you could use.

    It's also possible that your DBAs will be willing to have one of their DB Links used to create a materialized view of S2.Table2 on the S1 instance.

    Another option might be web services, but my guess is you'd run into much more administrative issues there than you would with a simple DB link. Consider those only if there are good reasons for no links (example: two separate organizations that don't want to open firewall holes between their databases).

    Failing those, you're getting into really ugly territory but you might be able to make something work. For example:

    • Open up both from a tool that can read from multiple connections at once and do the join there. Access. Toad for Data Analysis, whatever.
    • Use a tool like Toad to copy S2.Table2 to your own schema ("create in another schema" followed by "copy data to another schema")
    • If you have, or can get, complementary directory objects defined on both servers, create a Materialized View of S2 as an external table in a directory which can be written from S2 and read from S1.

    You really don't want to maintain any of these solutions over the long term, though.

提交回复
热议问题