Oracle’s database link allows user to query on multiple physical databases.
Is there any MySQL equivalent ? Workaround ?
I want to run a join query on two tables , which are in two physical databases. Is it possible in MySQL ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I can think of four possible workarounds for your scenario:
dbname.tablename-syntax to access tables outside the current database scope. This requires that the currently connected user has the appropriate rights to read from the requested table in another physical db.FEDERATEDMySQL storage engine to virtually import the table into your current database. This lifts the requirement of giving the current user access rights into the second database as the credentials are given with theCREATE TABLE-statement when using theFEDERATEDstorage engine. This also works with the databases running on different physical servers or different MySQL instances. I think that this will be the poorest performing option and does have some limitations – more or less important depending on your usage scenario and your requirements.SELECT <<columns>> FROM <<database>>.<<table>>. This resemble the way, theFEDERATED-method works, but is limited to tables on the same MySQL instance.Personally I’d consider method (4) as the most useful – but the others could also be possible workarounds depending on your requirements.