shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

about "not support sql contains schema"

Open zero2hj opened this issue 6 years ago • 3 comments

Question

hi, the following is described in the doc:

Do not support SQL that contains schema, for the concept of ShardingSphere is to use multiple data source as one data source, so all the SQL visits are based on one logic schema.

our application were build above two schema's data in one database. when we transform from mysql to sharding-proxy, we map each schema to one datasource in (is this the right way?). If we do so, there leave many sql contains schema which will not work in sharding-proxy, which will report 'table doesn't exist'. Then my question is how to do with it Thx

zero2hj avatar Aug 21 '20 07:08 zero2hj

our application were build above two schema's data in one database. when we transform from mysql to sharding-proxy, we map each schema to one datasource in (is this the right way?)

It is not the right way. Please imagine that there is only single database if databases managed by ShardingSphere. User do not need to care about schema name. So, the right way is config that 2 data sources as sharding db and managed by ShardingSphere's sharding feature.

terrymanu avatar Aug 24 '20 04:08 terrymanu

I have config those two data sources. Sorry, I can't get your idea clearly. I'll just introduce my situation to see if you can help. Thx. We create one database for each customer, e.g. cust1, cust2. show databases will see these two dbs.

cust1
cust2

We used to have SQL like this: select * from cust1.table(use cust2's jdbc data source)。We have requirements of querying across two schemas 's(cust1, cust2) data.

So, the right way is config that 2 data sources as sharding DB

As you say, I have created two logic schema.

  1. config-cust1.yml 2. config-cust2.yml.

Finally, we met the problem-db1.table not exists, when executing the above SQL.

zero2hj avatar Aug 26 '20 09:08 zero2hj

Two points here: 1、Actually, we recommend store multiple customers data in a uniformed logic database and use sharding key like userid%16 to isolate customer's data. 2、If each customer hold his only database, an independent datasource is suggested for this case.

kimmking avatar Sep 21 '20 11:09 kimmking