apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.89k stars 6.73k forks source link

Under one mysql instance, two database schemas, how to join tables cross schemas #30834

Closed songcheng1658 closed 3 months ago

songcheng1658 commented 6 months ago

I have a mysql database with 2 schemas: schema_a, schema_b; How to config sharding sphere to support:

select * from schema_a.table_a a join schema_b.table_b b on a.id=b.id;

zihaoAK47 commented 6 months ago

Hello, you can try using federated querying to address the issue. You can refer to the documentation for relevant configuration guidance.

https://shardingsphere.apache.org/document/current/en/features/sql-federation/

songcheng1658 commented 6 months ago

Hello, you can try using federated querying to address the issue. You can refer to the documentation for relevant configuration guidance.

https://shardingsphere.apache.org/document/current/en/features/sql-federation/

感谢你的回复;我还有问题

我尝试了【联邦查询】,发现有报错,有坑; 但是我的问题是,我在【一个msyql实例】上的【两个database数据库】; 程序没有能够识别出这个情况,还是要走【联邦查询】; 为什么,不能自动识别是在一个【数据库实例】,直接用mysql的【跨库能力】; 这样起码能解决,我们这种,只有【一个数据库实例】,【多个库】,从而利用mysql的本地跨库能力; 或者是我还没配置好,所以sharding sphere没有能够识别出这种场景

I tried [Federal Query] and found that there were errors and pitfalls; But my problem is that I have [two database databases] on [one msyql instance]; The program failed to recognize this situation and still has to go to [Federal Query]; Why, it cannot be automatically recognized that it is in a [database instance], directly use mysql's [cross-database capability]; This can at least solve the problem. We only have [one database instance] and [multiple libraries], so we can take advantage of MySQL's local cross-database capabilities; Or maybe I haven't configured it yet, so sharding sphere is not able to recognize this scenario.

github-actions[bot] commented 5 months ago

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

terrymanu commented 3 months ago

I don't think "library" is a concept related to ShardingSphere. Due to the high cost of understanding, please allow me to close this issue.