You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/05/18 07:55:33 UTC

[GitHub] [shardingsphere] grapeqin commented on issue #17719: If I want to split only the database, not the table. Do I need to configure rules for each table?

grapeqin commented on issue #17719:
URL: https://github.com/apache/shardingsphere/issues/17719#issuecomment-1129690802

   I think split database is base of split table,for example:
   two databases : ds_0 、ds_1
   
   two tables : tb0、tb1
   
   if we want to split database , we aim at tb0 split database. in this case , tb1 can not config at file,so this table is not split.
   
   we can config like this :
   ```yaml
   dataSources:
     ds_0:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.jdbc.Driver
       jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
       username: root
       password: 123456
     ds_1:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.jdbc.Driver
       jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
       username: root
       password: 123456
   
   rules:
   - !SHARDING
     tables:
       tb0:
         actualDataNodes: ds_${0..1}.tb0
         keyGenerateStrategy:
           column: account_id
           keyGeneratorName: snowflake
     defaultDatabaseStrategy:
       standard:
         shardingColumn: user_id
         shardingAlgorithmName: database-inline
     defaultTableStrategy:
       none:
     
     shardingAlgorithms:
       database-inline:
         type: INLINE
         props:
           algorithm-expression: ds_${user_id % 2}
       
     keyGenerators:
       snowflake:
         type: SNOWFLAKE
   ```


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