1.1 按照水平分库的方式创建数据库和数据表
1.1.1 创建分库1
CREATE SCHEMA `edudb1` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ;
1.1.2 创建分库2
CREATE SCHEMA `edudb2` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ;
1.1.3 创建分库1中的表1
CREATE TABLE `edudb1`.`course1` ( `cid` BIGINT NOT NULL, `cname` VARCHAR(45) NOT NULL, `user_id` BIGINT NOT NULL, `cstatus` VARCHAR(45) NOT NULL, PRIMARY KEY (`cid`));
1.1.4 创建分库1中的表2
CREATE TABLE `edudb1`.`course2` ( `cid` BIGINT NOT NULL, `cname` VARCHAR(45) NOT NULL, `user_id` BIGINT NOT NULL, `cstatus` VARCHAR(45) NOT NULL, PRIMARY KEY (`cid`));
1.1.5 创建分库2中的表1
CREATE TABLE `edudb2`.`course1` ( `cid` BIGINT NOT NULL, `cname` VARCHAR(45) NOT NULL, `user_id` BIGINT NOT NULL, `cstatus` VARCHAR(45) NOT NULL, PRIMARY KEY (`cid`));
1.1.6 创建分库2中的表2
CREATE TABLE `edudb2`.`course2` ( `cid` BIGINT NOT NULL, `cname` VARCHAR(45) NOT NULL, `user_id` BIGINT NOT NULL, `cstatus` VARCHAR(45) NOT NULL, PRIMARY KEY (`cid`)