You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "MrZhangsun (via GitHub)" <gi...@apache.org> on 2023/06/25 10:42:12 UTC

[GitHub] [shardingsphere] MrZhangsun commented on issue #2298: How to execute ddl in specified DB by sharding-jdbc

MrZhangsun commented on issue #2298:
URL: https://github.com/apache/shardingsphere/issues/2298#issuecomment-1606018703

   during sharding jdbc initialization, it will do three things:
   1. load all exist tables from all ds;
   2. calculate the actual-data-nodes by configured shard rule(list all actual table name, even it does't exist);
   3. classify all tables to two types: sharding tables and single tables;
       3.1. the sharding tables are calculated by configured shard rule;
       3.2. the single tables are the intersection of the database tables and the sharding tables subtracted from the tables already existing in the database;
   
   if you created a table dynamically, the sharding jdbc does't known which type it is. when you use the dynamic table, if you use the logic table name with sharding key, then sharding jdbc will calculate the actual data table name by logic table name and sharding key. if the calculated actual table name exists in "actual-data-nodes" and it exists in database, then you can use it correctly.
   
   otherwise, you use it directly, that also, you use the actual data table name, sharding jdbc will route database by single table rule. when sharding jdbc can't find the table name from calculated single tables,  it will use the first datasource of configuration: "spring.shardingsphere.database.names: ds0, ds1, ds..."  as the default datasource, which we can't change it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org