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

[GitHub] [shardingsphere] sunyijian opened a new issue, #26164: Questions about the AutoTable

sunyijian opened a new issue, #26164:
URL: https://github.com/apache/shardingsphere/issues/26164

   ## Question
   
   application.yml :
   ```
           autoTables:
             t_order:
               actualDataSources: ds$->{1..2}
               sharding-strategy:
                 standard:
                   sharding-column: orderId
                   sharding-algorithm-name: hash-mod-algorithm-4
           sharding-algorithms:
             hash-mod-algorithm-4:
               type: HASH_MOD
               props:
                 sharding-count: 4
   ```
   Tables t_order_0 and t_order_3 in ds1.
   Tables t_order_1 and t_order_2 in ds2.
   About Recommended Scenarios for Using Autotable:  The user only tells the shardingSphere the number of shards and does not need to worry about which library the actual tables are in or how many tables are in which library.
   I think shardingSphere should be able to automatically identify the relationship between these four tables and the data source. Actually, it doesn't work.
   console log:
   ```
   ShardingSphere-SQL                       : Actual SQL: ds1 ::: select * from t_order_0  order by orderId desc
   ShardingSphere-SQL                       : Actual SQL: ds1 ::: select * from t_order_2  order by orderId desc
   ShardingSphere-SQL                       : Actual SQL: ds2 ::: select * from t_order_1  order by orderId desc
   ShardingSphere-SQL                       : Actual SQL: ds2 ::: select * from t_order_3  order by orderId desc
   
   com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ds1.t_order_2' doesn't exist
   com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'ds2.t_order_3' doesn't exist
   ``
   
   The log tells me that Tables t_order_0  and t_order_2  should be in ds1, and t_order_1  and t_order_3  should be in ds2. Should I follow this plan to adjust my database。
   What should I do to align with the concept of autoTable?


-- 
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.apache.org

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


[GitHub] [shardingsphere] sunyijian closed issue #26164: Questions about the AutoTable

Posted by "sunyijian (via GitHub)" <gi...@apache.org>.
sunyijian closed issue #26164: Questions about the AutoTable
URL: https://github.com/apache/shardingsphere/issues/26164


-- 
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


[GitHub] [shardingsphere] dongguo4812 commented on issue #26164: Questions about the AutoTable

Posted by "dongguo4812 (via GitHub)" <gi...@apache.org>.
dongguo4812 commented on issue #26164:
URL: https://github.com/apache/shardingsphere/issues/26164#issuecomment-1682189922

   你可以让shardingsphere帮你创建表 
   for example 
   `    @Autowired
       JdbcTemplate jdbcTemplate;
   
       @Test
       public void testCreateAutoOrderMod() {
           jdbcTemplate.execute("CREATE TABLE t_order (\n" +
                   "  order_id BIGINT,\n" +
                   "  order_no VARCHAR(30),\n" +
                   "  user_id BIGINT,\n" +
                   "  amount DECIMAL(10,2),\n" +
                   "  PRIMARY KEY(order_id) USING BTREE\n" +
                   ") ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;");
           for (long i = 1; i <= 10; i++) {
               Order order = new Order();
               order.setOrderNo("SP20230814000" + i);
               order.setUserId(i);
               order.setAmount(new BigDecimal(100));
               orderMapper.insert(order);
           }
       }`
   shardingsphere按照分片规则创建表,这样查询就没有问题了


-- 
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