Multiple databases in a single query

I need to query multiple databases in a single query.
e.g.
Database d1 contains table t1 with column id
Database d2 contains table t2 with column id
I need a query like
SELECT * FROM t1, t2 WHERE t1.id = t2.id;
is this possible in jdbc? if yes can anyone help with some sample code?
thanks,
Ashish Saraf

It is not possible using the JDBC API to query tables in two or more databases using a single query. The reason is that a JDBC Connection is made to a single data source.
However, some databases support the idea of federations or linked tables. What you do is inside the database manager link or federate a table that is present in another DBMS. Then, pose a single JDBC query to the one DBMS which will have its own table and links to the external tables.
Another approach is to use a special JDBC driver with a built-in integration engine that will perform a query across multiple databases. In effect, the system poses separate queries to the different databases and integrates and joins the data together for you automatically on the client-side. That is much easier than doing it yourself in code, but that is also possible for simple queries.
As part of my research program, we have released a shareware version of the UnityJDBC driver that can query multiple databases using a single SQL query. For more information, see:
http://www.unityjdbc.com
http://www.cs.uiowa.edu/~rlawrenc/research/projects.html
Sincerely,
Dr. Ramon Lawrence
Assistant Professor
Department of Computer Science
University of Iowa
[email protected]

Similar Messages

  • How to calculate the individual sums of multiple columns in a single query

    Hello,
    Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
    Will appreciate any help or suggestion.
    Thanks

    user13667036 wrote:
    Hello,
    Using Oracle 11gR2 on windows 7 client. I have a question on calculating sum() on multiple columns on different columns and store the results in a view. Unfortunately I could not post the problem here as it keeps on giving error "Sorry, this content is not allowed", without telling where or what it is! So I had to post it in the stack-overflow forum, here is the link: http://stackoverflow.com/questions/16529721/how-to-calculate-the-individual-sums-of-multiple-columns-in-a-single-query-ora
    Will appreciate any help or suggestion.
    ThanksLooks like you want a simple group by.
    select
              yr
         ,      mnth
         ,      region
         ,     sum(handled_package)
         ,     sum(expected_missing_package)
         ,     sum(actual_missing_package)
    from test
    group by
         yr, mnth, region
    order by      
         yr, mnth, region;I wouldn't recommend storing your data for year / month in 2 columns like that unless you have a really good reason. I would store it as a date column and add a check constraint to ensure that the date is always the first of the month, then format it out as you wish to the client.
    CREATE TABLE test
         year_month                              date,
        Region                     VARCHAR2(50),
        CITY                       VARCHAR2(50),             
        Handled_Package            NUMBER,       
        Expected_Missing_Package   NUMBER,   
        Actual_Missing_Package     NUMBER
    alter table test add constraint firs_of_month check (year_month = trunc(year_month, 'mm'));
    ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
      2  Values (to_date('2012-nov-12', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
    Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
    ERROR at line 1:
    ORA-02290: check constraint (TUBBY.FIRS_OF_MONTH) violated
    Elapsed: 00:00:00.03
    ME_XE?Insert into TEST (year_month, REGION, CITY, HANDLED_PACKAGE, EXPECTED_MISSING_PACKAGE, ACTUAL_MISSING_PACKAGE)
      2  Values (to_date('2012-nov-01', 'yyyy-mon-dd'), 'Western', 'San Fransisco', 200, 10, 5);
    1 row created.
    Elapsed: 00:00:00.01
    ME_XE?select
      2        to_char(year_month, 'fmYYYY')    as year
      3     ,  to_char(year_month, 'fmMonth')   as month
      4     ,  Region
      5     ,  CITY
      6     ,  Handled_Package
      7     ,  Expected_Missing_Package
      8     ,  Actual_Missing_Package
      9  from test;
    YEAR         MONTH                REGION                         CITY                    HANDLED_PACKAGE EXPECTED_MISSING_PACKAGE ACTUAL_MISSING_PACKAGE
    2012         November             Western                        San Fransisco                       200                       10                      5
    1 row selected.
    Elapsed: 00:00:00.01
    ME_XE?Then you have nice a nice and easy validation that ensures you data integrity.
    Cheers,

  • How to add multiple databases for a single frontend

    We have a project based on distributed databases and we have to workout on .Net framework.I want to know some information of connecting multiple databases for a single frontend and how can we access them.
    If so we have connected 2 databases for a single frontend in future if I want add one more database to it how it will be possible to do it without disturbing the current connectivity.
    Please help me in resolving this problem.
    Thanks......

    hi,
    what do you mean by connecting 2 databases? can you explain further?
    using entityframework you can connect to different databases
    public class CustomerContext : DbContext
    public ReportContext()
    : base("DefaultConnection")
    public DbSet<Customers> Customers { get; set; }
    and your connectionstring (config file)
    <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=D:\\Database\Project.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
    you can add more connection strings on it.
    https://msdn.microsoft.com/en-us/library/vstudio/cc716756(v=vs.100).aspx
    https://msdn.microsoft.com/en-us/library/ms254978(v=vs.110).aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • How to insert multiple records in a single query

    Dear all,
    Can you please tell
    how to insert multiple records in a single query ??

    INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
    INSERT INTO table_name
    (column_1, column_2)
    SELECT 'value_A', 'value_B' FROM DUAL
    UNION ALL
    SELECT 'value_C', 'value_D' FROM DUAL
    ;Edited by: Benton on Nov 9, 2010 1:59 PM

  • How to access multiple database present in single instance

    Hi Team,
    In oracle 11.2, can there be multiple databases in an instance???  In one of our environment, I could see multiple databases in an instance. Could you please help me in giving the data dictionary or query to access those databases?
    Actually, querying v$database, I could see only one database which is same as instance name. But in inventory, there are multiple database in an instance?
    I am still not exactly clear about this. Can someone help me with this?
    Thanks!
    Vidhya

    In Oracle one instance manages one (1) database. A database consists of multiple *schemas*.
    Other vendors erroneously call a schema 'database'.
    So, no, you didn't see multiple databases.
    There is also one datadictionary, consisting of a set of views.
    All views beginning with dba_  list the entire database, all schemas.
    All views beginning with all_ list the objects you have access to.
    All views beginning with user_ list your own objects.
    The view DICT show you the contents of the datadictionary.
    Oracle also has online documentation at http://docs.oracle.com
    From your question it is clear you should read the document called the 'Oracle Concepts Manual'.
    You can find all documentation for 11gR2 here Oracle Database Online Documentation 11g Release 2 (11.2)
    Too many people here don't make any effort to read it. This is probably the reason why you got no response.
    Sybrand Bakker
    Senior Oracle DBA

  • Multiples Databases in a single Report

    Hi all experts...
    How I can create a parameter to chosse multiples databases... In a single report!
    regards

    Wagner,
    If you have CR Server installed on your network, you can use the Business View Manager to create a Dynamic Data Connection.
    As soon as you add the Business View to your report as the data source, a choose database parameter will be added to your report automatically.
    Also, if your BIG idea works out, please post it. We all love new ideas. Especially when they work.
    Jason

  • Multiple databases in one single RAC cluster

    Hi, I would like to know if one can have multiple databases running on a single RAC cluster, we have several databases in our shop and would like to consolidate all of them into a single 3-4 node RAC cluster running databases with 10.2 and 11.1 versions.
    I am newbie to RAC and would like to get some clarification if anyone has done this, google search comes up with few hits on this topic, so obviously this is not doable.
    In our case we have one database supporting critical applications and few other not so critical but are used very extensively between 9-5, so what is the use of RAC if I cannot consolidate all my databases into one cluster, or if I need a separate cluster for each of these critical databases?
    I have been all the Oracle docs that keep repeating one database multiple instances and one instance-one machine-one node, they don't even advise running multiple instances on a single node?.
    I appreciate any insight.
    Thanks.

    ora-sql-dba wrote:
    Can you give more details on how you would setup multiple databases running different versions on a single RAC cluster, I am yet to find any documentation that supports or even elaborates on this topic.You can configure a cluster with 12 nodes. Then, using dbca, configure a dev instance for nodes 1 and 2, a prod1 instance for nodes 3 to 6 and a prod2 instance for nodes 7 to 12.
    You also can configure each of these instances for all 12 nodes. And use it on all 12 nodes.
    Or, after configuring it for all 12 nodes, you can start the dev instance on nodes 1 and 2, prod1 on 3 - 6 and prod2 on the remaining nodes. If dev needs more power, you can for example shutdown prod2 on node 12 and start another dev instance there.
    My issue is with the 2nd option - running more than one instance on the same node or server. Why? Each instance has a basic resource footprint ito shared memory needed, system processes required (like db writer, log writer, sys monitor) etc. It does not make sense to pay for that same footprint more than once on a server. Each time you do, you need to reduce the amount of resources that can be used by each instance.
    So instead of using (for example) 60% of that server's memory as the SGA for a single instance, if you use 2 instances on that server you now have to reduce the SGA of each to 30% of system memory. Effectively crippling those instances by 50% - they will now have smaller buffer caches, require more physical I/O and be more limited in what they can do.
    So unless you have very sound technical reasons for running more than one instance on a server (RAC or non-RAC), do not.

  • Query Design Strategies - servicing multiple reports from a single query

    I was wondering if anyone knew of any good web resrouces (articles and such) to assist with Query Design Strategies. What I am specifically looking to do is replace multiple reports from the previous system with just views of a single query. So I was looking at grouping the existing reports that we are replacing into queries and creating views for each report.
    The catch is that we will only be utilizing web reporting for report distribution, so we need to:
    1. Use views as DataProviders to web templates
    2. Broadcast views to users as links where they can see that particular view
    Is this possible and does anyone have some info on how to do this?

    Lets say that 10 broadcasted reports all could use the same query but each in a different navigational state.
    1. Can you navigate the query and save as a view and then set up a brodacast rule for that view?
    2. Can a DataProvider in a web template be a view?
    3. Can the BI Launcher iView take a view name in place of a query?
    <prt_protcl>://<prt_server>/<bi_launcher>?TEMPLATE=TEST1&QUERY=TEST2

  • Updating multiple node in a single query

    Hi
    Shall I update multiple nodes (which satisfies the given condition) in a single query? From the prototype we suspect that all nodes in all document are not updated in the container.
    Version: BDB XML 2.4 - Fedora core 4 Linux - C++ language
    Query:
    replace value of node collection()/File[@Id="57565C01327A"]//Entry[@Class="Measurement" and @Id="0"]/Attribute[@Name="apDlBhUtil"]/@Value with 8'
    Result:
    XmlException occurred with msg 'Error: Sequence does not match type node() - the sequence contains more than one item [err:XUTY0008], <query>:1:1'
    We have tried running the query in both Lazy and Eager evaluation type. Please clarify that the issue is with the query/execution type or BDB XML doesn't support this feature?
    Thanks
    Santhosh

    Santhosh,
    Try:
    for $i in collection()/File[@Id="57565C01327A"]//Entry[@Class="Measurement" and @Id="0"]/Attribute[@Name="apDlBhUtil"]/@Value return replace value of node $i with 8'The problem with your original is that the argument for "replace value of" needs to be a single item, not a sequence.
    Regards,
    George

  • Multiple Database Instances on Single Server and effect of NLS_LANG

    What is the effect of the NLS_LANG registry setting on a Windows server that is to host multiple database instance each created with a different database character set ? The server needs to support data in the following languages : Thai, Chinese Traditional, Chinese Simplified, Vietnamese and Korean. Selecting the Unicode character set(AL32UTF8) is not an option since the application is not Unicode complaint.
    My understanding is that as long as NLS_LANG is set correctly on the client connecting to the particular database instance then the data will be stored correctly - is this correct ?
    What should NLS_LANG be set to on the server if there are multiple oracle instances with different character sets ?

    My question is not in relation to connecting to the database on the server itself but with regards to client connections. What I need to know is what is the effect of the NLS_LANG setting in the registry on a server that has multiple databases each created with a different character set ?
    Say for instance, the server has two databases - one created with the character set ZHS16GBK and the other created with the character set JA16SJIS and NLS_LANG is set to SIMPLIFIED CHINESE_CHINA.ZHS16GBK in the registry on the server. Will Japanese data that is inserted into the database that has character set JA16SJIS be stored correctly when it is inserted from a client with NLS_LANG set to JAPANESE_JAPAN.JA16SJIS even though NLS_LANG is set to SIMPLIFIED CHINESE_CHINA.ZHS16GBK on the server ?

  • How to use multiple aggregate functions in single query

    hi to all
    The output will be giving first_name,last_name,max(salary),min(salary) and the output will be department wise.From employees table in single query
    output will be:
    first_name|last_name|max(salary)|min(salary)

    SELECT first_name||' '||last_name as ename,
           MIN(sal) KEEP (DENSE_RANK FIRST ORDER BY sal) OVER (PARTITION BY deptno) "Lowest",
           MAX(sal) KEEP (DENSE_RANK LAST ORDER BY sal) OVER (PARTITION BY deptno) "Highest"
    FROM   emp
    ORDER BY deptno, sal;Edited by: Ramio on Jan 10, 2012 10:43 PM

  • Connection to multiple databases using a single EJB

    How can I connect to multiple Databases (using @PersistenceContext) using an EJB?
    Did I need to connect various Entity Managers corresponding to the each database and simply send my Queries?
    I am using Glassfish Application Server
    Netbeans IDE
    Java Derby Database
    Oracle Database
    Java Persistence API
    Thanks in Advance

    Yes, you need a persistence context and thus entity manager per database. Depending on what you want to achieve you may also need to go to the next level in your skill set and learn all about distributed transactions.

  • How to calculate multiple aggregation in a single query

    how to find firstname ,lastname for max and min salary from employees table group by department in a single query?
    Edited by: Gnanasekar on Jan 10, 2012 6:36 AM

    check this query
    select ENAME,SAL
    from EMP
    where SAL in(select max(SAL)
                       from EMP
                      group by DEPTNO)
    or SAL in(select min(SAL)
                 from EMP
                  group by DEPTNO)Hope this will help you..
    You should ask this question at sql/plsql forum
    If someone's response is helpful or correct, please mark it accordingly.

  • Display Multiple reports in a single query view

    Hi Team,
    I have 3 similar reports for MTD, QTD & YTD.
    While displaying the report in the portal..  I want to display the reports in a single view wherein the MTD report will be a default report for the input selections. whereas the QTD & YTD will be available as dropdown options in the same query view and the wll be executed for the same input selections.
    Please advice how to design the view.
    Regards
    Sneha

    Hi All,
    I have created a Web Template for my requirement.
    Now while adding the template to my Transport request, I am getting the following error message:
    Object 'BTMP::0ANALYSIS_PATTERN_EXPORT' refers to the invalid object 'QU::'
    Object 'BTMP::0ANALYSIS_PATTERN_INFO' refers to the invalid object 'QU::'
    PLEASE ADVICE...
    Regards
    Sneha
    Edited by: Sneha Santhanakrishnan on Aug 8, 2011 12:18 PM

  • Opening multiple databases in a single file

         Hello everybody, I need create 1000 small databases(tables) in a single physical file, how to solve? ( I have read chap 3 Access Method Operations in BDB programmer reference,  so I know it’s need create a shared database environment, but I don’t know which ENV FLAG or API I need .)
         thank you very much.

    I would suggest taking a look at the example programs in the /examples directory in the install.   ex_env.c covers basics on creating an environment and creating a database in that environment.   This program could be easily modified to create 1000 databases.
    thanks
    mike

Maybe you are looking for

  • How to get the PO no in the smart form and in the print program from ME23N

    hello all,                  I am new to smart form printing.I want to make a smartform along with print program that will show PO Details.It has to be created as an o/p type in ME23N. I have created an o/p type ZPO using NACE ..Can some one tell me h

  • How do I add a quote to an individual photo I took?

    how do I add a quote to an individual photo I took? And is there a way to change the background color on the photo. The pics are in my photo gallery taken with my ipad <Re-Titled By Host>

  • Avail service tax and its Eces,SECESS?

    hii all, Can some body explain me about the service tax scenrio with ecess and secess. how to avail the service tax ,ecess on service tax and secess on service tax. Explaination in detailed way is appreciable. thanks

  • Search bar isn't working.

    Searching from the address bar does nothing. Typing searches in the search bar does nothing. Under "Manage Search Engines", all options are greyed out, and clicking "get more search engines" does nothing. I've started in Safe Mode with the same resul

  • Modbus comm fails

    Lookout alarm messages (comm fails) occur with Lookout 6.5 running on Windows 7 computer.  Comm fails do not occur with Lookout 6.5 running on Windows XP computer.  Communications are dial-up mode.  Both computers have Conexant modems.  Communicaton