How to connect to 2 databases in one session

Help
W M
2010-11-17
2013-04-29
  • W M
    W M
    2010-11-17

    Hello,

    does anyone know how to connect to connect to 2 databases in one session?

    e.g.:  Select * from DB1.customer inner join DB2.customer

    any idea
    Wolfi

     
  • Heiko Hilbert
    Heiko Hilbert
    2010-11-17

    It depends on the database you are using and what you mean with DB1 and DB2. In mysql or sybase for instance you can query tables from different databases in the same sql server. The symtax is likme you did above.
    MySql:
    Select * from DB1.customer inner join DB2.customer
    Sybase:
    Select * from DB1..customer inner join DB2..customer
    If you mean different SQL servers with DB1 and DB2 this is not so eays. Oracel has database links to view remote tables. MySql supports federated tables and I think sybase has a remote tables called proxy table.
    These all are databse provider specific solutions. AFAIK there is a JDBC driver called CJDBC (clustered JDBC?) which can map tables to different SQL connections on the client side. Perhaps you can try this.