## 配置ds0 和ds1两个数据源
#spring.shardingsphere.datasource.names=ds,ds0,ds1
##ds1 配置
#spring.shardingsphere.datasource.ds.type=com.alibaba.druid.pool.DruidDataSource
#spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.shardingsphere.datasource.ds.url=jdbc:mysql://localhost:3306/micromall?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
##初始连接数
#spring.shardingsphere.datasource.ds.initialSize=5
##最小空闲连接数
#spring.shardingsphere.datasource.ds.minIdle=10
##最大连接数
#spring.shardingsphere.datasource.ds.maxActive=30
#spring.shardingsphere.datasource.ds.validationQuery=SELECT 1 FROM DUAL
#spring.shardingsphere.datasource.ds.username=root
#spring.shardingsphere.datasource.ds.password=root
##ds0 配置
#spring.shardingsphere.datasource.ds0.type=com.alibaba.druid.pool.DruidDataSource
#spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.shardingsphere.datasource.ds0.url=jdbc:mysql://localhost:3306/micromall_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
#spring.shardingsphere.datasource.ds0.initialSize=5
#spring.shardingsphere.datasource.ds0.minIdle=10
#spring.shardingsphere.datasource.ds0.maxActive=30
#spring.shardingsphere.datasource.ds0.validationQuery=SELECT 1 FROM DUAL
#spring.shardingsphere.datasource.ds0.username=root
#spring.shardingsphere.datasource.ds0.password=root
##ds1 配置
#spring.shardingsphere.datasource.ds1.type=com.alibaba.druid.pool.DruidDataSource
#spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.shardingsphere.datasource.ds1.url=jdbc:mysql://localhost:3306/micromall_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
#spring.shardingsphere.datasource.ds1.initialSize=5
#spring.shardingsphere.datasource.ds1.minIdle=10
#spring.shardingsphere.datasource.ds1.maxActive=30
#spring.shardingsphere.datasource.ds1.validationQuery=SELECT 1 FROM DUAL
#spring.shardingsphere.datasource.ds1.username=root
#spring.shardingsphere.datasource.ds1.password=root
#
## 对于没有做任何业务拆分的表，直接走本默认数据源即可
#spring.shardingsphere.sharding.default-data-source-name=ds
#
#spring.shardingsphere.sharding.default-database-strategy.hint.algorithm-class-name=com.tuling.tulingmall.sharding.OrderAllRangeHintAlgorithm
#spring.shardingsphere.sharding.default-table-strategy.hint.algorithm-class-name=com.tuling.tulingmall.sharding.OrderAllRangeHintAlgorithm
## oms_order分片策略
## 节点 ds0.oms_order_0,ds0.oms_order_1,ds1.oms_order_0,ds1.oms_order_1
#spring.shardingsphere.sharding.tables.oms_order.actual-data-nodes=ds$->{0..1}.oms_order_$->{0..1}
##分库策略
#spring.shardingsphere.sharding.tables.oms_order.database-strategy.inline.sharding-column=id
#spring.shardingsphere.sharding.tables.oms_order.database-strategy.inline.algorithm-expression=ds$->{id % 2}
## 分表策略
#spring.shardingsphere.sharding.tables.oms_order.table-strategy.inline.sharding-column=id
## 注意下，对于除法，groovy会计算出浮点数，而不是整数。即 3/2=1.5，如果需要计算出整数 3.intdiv(2)=1
#spring.shardingsphere.sharding.tables.oms_order.table-strategy.inline.algorithm-expression = oms_order_$->{((id+1) % 4).intdiv(2)}
## 复合分片算法
##spring.shardingsphere.sharding.tables.oms_order.table-strategy.complex.sharding-columns=id
##spring.shardingsphere.sharding.tables.oms_order.table-strategy.complex.algorithm-class-name = com.tuling.tulingmall.sharding.OrderComplexShardingAlgorithm
## 使用SNOWFLAKE算法生成主键
#spring.shardingsphere.sharding.tables.oms_order.key-generator.column=id
#spring.shardingsphere.sharding.tables.oms_order.key-generator.type=SNOWFLAKE
#spring.shardingsphere.sharding.tables.oms_order.key-generator.props.worker.id=123
## 使用自定义主键生成策略
##spring.shardingsphere.sharding.tables.oms_order.key-generator.type=CUSTOM
##spring.shardingsphere.sharding.tables.oms_order.key-generator.props.redis.prefix=order:id:prefix:
#
## 节点 ds0.oms_order_item_0,ds0.oms_order_item_1,ds1.oms_order_item_0,ds1.oms_order_item_1
#spring.shardingsphere.sharding.tables.oms_order_item.actual-data-nodes=ds$->{0..1}.oms_order_item_$->{0..1}
## 分库策略 按order_id分片
#spring.shardingsphere.sharding.tables.oms_order_item.database-strategy.inline.sharding-column=order_id
#spring.shardingsphere.sharding.tables.oms_order_item.database-strategy.inline.algorithm-expression=ds$->{order_id % 2}
## 分表策略
#spring.shardingsphere.sharding.tables.oms_order_item.table-strategy.inline.sharding-column=order_id
#spring.shardingsphere.sharding.tables.oms_order_item.table-strategy.inline.algorithm-expression=oms_order_item_$->{((order_id+1) % 4).intdiv(2)}
## 使用SNOWFLAKE算法生成主键
#spring.shardingsphere.sharding.tables.oms_order_item.key-generator.column=id
#spring.shardingsphere.sharding.tables.oms_order_item.key-generator.type=SNOWFLAKE
#spring.shardingsphere.sharding.tables.oms_order_item.key-generator.props.worker.id=123
#
## 配置绑定表，防止笛卡尔乘积
#spring.shardingsphere.sharding.binding-tables[0]=oms_order,oms_order_item
## 打印SQL语句
#spring.shardingsphere.props.sql.show=true
#
##配合SeataATOrderService示例配置
##spring.shardingsphere.datasource.names=ds0,ds1
##
##spring.shardingsphere.datasource.ds0.type=com.alibaba.druid.pool.DruidDataSource
##spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
##spring.shardingsphere.datasource.ds0.url=jdbc:mysql://localhost:3306/micromall_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
##spring.shardingsphere.datasource.ds0.initialSize=5
##spring.shardingsphere.datasource.ds0.minIdle=10
##spring.shardingsphere.datasource.ds0.maxActive=30
##spring.shardingsphere.datasource.ds0.validationQuery=SELECT 1 FROM DUAL
##spring.shardingsphere.datasource.ds0.username=root
##spring.shardingsphere.datasource.ds0.password=root
##
##spring.shardingsphere.datasource.ds1.type=com.alibaba.druid.pool.DruidDataSource
##spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
##spring.shardingsphere.datasource.ds1.url=jdbc:mysql://localhost:3306/micromall_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
##spring.shardingsphere.datasource.ds1.initialSize=5
##spring.shardingsphere.datasource.ds1.minIdle=10
##spring.shardingsphere.datasource.ds1.maxActive=30
##spring.shardingsphere.datasource.ds1.validationQuery=SELECT 1 FROM DUAL
##spring.shardingsphere.datasource.ds1.username=root
##spring.shardingsphere.datasource.ds1.password=root
##
##spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=user_id
##spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds$->{user_id % 2}
##
##spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order_$->{0..1}
##spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-column=order_id
##spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_$->{order_id % 2}
##
##spring.shardingsphere.sharding.tables.t_order.key-generator.column=order_id
##spring.shardingsphere.sharding.tables.t_order.key-generator.type=snowflake
##spring.shardingsphere.sharding.tables.t_order.key-generator.props.worker.id=123
