hitnewbee opened a new issue #5769:
URL: https://github.com/apache/shardingsphere/issues/5769


   table struct:
   | t_user_0 | CREATE TABLE `t_user_0` (
     `user_id` bigint(20) NOT NULL AUTO_INCREMENT,
     `username` varchar(30) NOT NULL,
     `password` varchar(30) DEFAULT NULL,
     `engines` varchar(50) DEFAULT NULL,
     PRIMARY KEY (`user_id`)
   ) ENGINE=InnoDB AUTO_INCREMENT=470908781660733445 DEFAULT CHARSET=utf8 |
   
   config-sharding.yaml:
   rules:
     - !SHARDING
       tables:
         t_user:
           actualDataNodes: ds_${0..1}.t_user_${0..1}
           tableStrategy:
             standard:
               shardingColumn: user_id
               shardingAlgorithm:
                 type: INLINE
                 props:
                   algorithm.expression: t_user_${user_id % 2}
           keyGenerator:
             type: SNOWFLAKE
             column: user_id
       bindingTables:
         - t_user
       defaultDatabaseStrategy:
         standard:
           shardingColumn: user_id
           shardingAlgorithm:
             type: INLINE
             props:
               algorithm.expression: ds_${user_id % 2}
       defaultTableStrategy:
         none:
   
   execute sql:
   mysql> insert into t_user(username) values(10);
   Query OK, 4 rows affected (0.21 sec)
   
   actual sql:
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual 
SQL: ds_0 ::: insert into t_user_0(username) values(10)
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual 
SQL: ds_0 ::: insert into t_user_1(username) values(10)
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual 
SQL: ds_1 ::: insert into t_user_0(username) values(10)
   [INFO ] 19:41:23.334 [ShardingSphere-Command-6] ShardingSphere-SQL - Actual 
SQL: ds_1 ::: insert into t_user_1(username) values(10)
   
   


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to