-
Data
sub-library sub-table concept and application scenarios Detailed
sub-library sub-table brought some problems
sharding-jdbc horizontal and vertical sub-library sub-table environment to build
sharding-jdbc level sub-library sub-table real
sharding-jdbc sub-library sub-table vertical combat -
Use docker to start two mysql databases
docker run -it -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 mysql docker run -it -e MYSQL_ROOT_PASSWORD=123456 -p 3307:3306 mysql
-
Horizontal sub-tables are created using tables
1. The structure is as follows:
2. Table sqlcreate table t_user_1 ( user_id bigint null, //用户id user_name varchar(20) null, //用户名称 user_age int null, //用户年龄 user_type int null //用户类型 1 会员 2 普通用户 ); create table t_user_2 ( user_id bigint null, //用户id user_name varchar(20) null, //用户名称 user_age int null, //用户年龄 user_type int null //用户类型 1 会员 2 普通用户 );
-
The horizontal sub-database uses tables to create
1. The structure is as follows:
2. Table sqlcreate table t_user ( user_id bigint null, //用户id user_name varchar(20) null, //用户名称 user_age int null, //用户年龄 user_type int null //用户类型 1 会员 2 普通用户 );
-
The vertical score table is
not tested, we use the vertical score table every day -
Vertical sub-database
1. Table structure
2. Table sqlcreate table t_order ( order_id bigint null, user_id bigint null, order_price int null );
-
Project environment
In order to let everyone know more about the configuration of sharding-jdbc, I decided to use spring-jdbc to access first, and then use mybatis and springBoot to know the detailed causes and consequences, so that everyone can understand better.1. Just create a java project, we use a simple main to do experiments, it is easier to set up the environment
2. Introduce the jar package<!--单独使用java代码配置方式--> <!-- https://mvnrepository.com/artifact/org.apache.shardingsphere/sharding-jdbc-core --> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>sharding-jdbc-core</artifactId> <version>4.1.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.3.17.RELEASE</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.47</version> </dependency> <!--druid--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.21</version> </dependency>
sharding-jdbc horizontal and vertical sub-database sub-table environment construction
Guess you like
Origin blog.csdn.net/weixin_38312719/article/details/109137533
Ranking