ShardingSphere(基本概念_sharding_jdbc)
https://shardingsphere.apache.org/index_zh.html
基本概念
什么是shardingsphere?

https://shardingsphere.apache.org/document/current/cn/overview/
什么是分库分表?

分库分表的方式

垂直切分
垂直分表
![]()

垂直分库

水平切分
水平分库

水平分表

分库分表应用及问题


Sharding-JDBC
简介



水平分表
搭建环境
![]()
依赖



创建数据库、表(按水平分表的方式)


code(实体类、mapper、test...)




application.properties配置
https://shardingsphere.apache.org/document/current/cn/user-manual/

![]()
testcode



水平分库分表

application.properties配置
https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/yaml-config/



testcode


垂直分库
需求

操作user表时,去user_db中操作,操作course表时,去course_db中操作;
创建数据库、表

编写测试代码


application.properties配置垂直分库



testcode

公共表
![]()

![]()

4、testcode



浙公网安备 33010602011771号