sharding: jdbc: config: sharding: tables: myorder: key-generator-column-name: id #主键 actual-data-nodes: db$->{0..1}.myorder_$->{0..1} #分库策略 database‐strategy: inline: sharding-column: id algorithm-expression: db$->{id%2} #分表策略 table-strategy: inline: sharding-column: id algorithm-expression: myorder_$->{id%2+1} orderitem: #test key-generator-column-name: id #主键 actual-data-nodes: db$->{0..1}.orderitem_$->{0..3} #数据节点,均匀分布 #分库策略 database‐strategy: inline: sharding-column: id algorithm-expression: db$->{id%2} table-strategy: inline: sharding-column: id algorithm-expression: orderitem_$->{id%2+1}
如果分了库分库策略一定要配置,
分了库即使没有分表的表也要配置分库分表策略,让程序知道表的具体位置