Comven commented on issue #13544:
URL:
https://github.com/apache/shardingsphere/issues/13544#issuecomment-966161131
table schema is like this
```
CREATE TABLE `order_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`order_no` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
DEFAULT '',
`user_id` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`add_time` datetime NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `order_no`(`order_no`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE =
utf8_general_ci COMMENT = '订单信息' ROW_FORMAT = Dynamic;
```
Split table by month.
database configuration like this
```
# shardingsphere config
spring.shardingsphere.props.sql-show=true
spring.shardingsphere.datasource.names=db1,db1slaver
spring.shardingsphere.datasource.db1.jdbc-url=jdbc:mysql://localhost:3306/sharding_one_master?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
spring.shardingsphere.datasource.db1.username=root
spring.shardingsphere.datasource.db1.password=****
spring.shardingsphere.datasource.db1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.db1slaver.jdbc-url=jdbc:mysql://localhost:3306/sharding_one_slaver?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
spring.shardingsphere.datasource.db1slaver.username=root
spring.shardingsphere.datasource.db1slaver.password=****
spring.shardingsphere.datasource.db1slaver.readOnly=true
spring.shardingsphere.datasource.db1slaver.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.db1slaver.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.rules.sharding.tables.order_info.actual-data-nodes=dbrwone.order_info_20$->{21..22}0$->{1..9},dbrwone.order_info_20$->{21..22}$->{10..12}
# order_info sharding config
spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.sharding-column=add_time
spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.sharding-algorithm-name=tb-month-sharding
# IntervalShardingAlgorithm
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.type=interval
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-interval-amount=1
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-interval-unit=Months
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.sharding-suffix-pattern=yyyyMM
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-pattern=yyyy-MM-dd
HH:mm:ss
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-lower=2021-06-01
00:00:00
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-upper=2022-12-31
23:59:59
# sharding_one read write config
spring.shardingsphere.rules.readwrite-splitting.dataSources.dbrwone.write-data-source-name=db1
spring.shardingsphere.rules.readwrite-splitting.dataSources.dbrwone.read-data-source-names=db1slaver
spring.shardingsphere.rules.readwrite-splitting.dataSources.dbrwone.load-balancer-name=roundRobin
# loadbalance config
spring.shardingsphere.rules.readwrite-splitting.load-balancers.roundRobin.type=ROUND_ROBIN
spring.shardingsphere.rules.readwrite-splitting.load-balancers.random.type=RANDOM
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]