# 创建表
说明
mysql fabric 官方第三方组件,用于多数据库切片
/*
Navicat Premium Data Transfer
Source Server : bjgc
Source Server Type : MySQL
Source Server Version : 50650
Source Host : 10.83.128.202:3306
Source Schema : db-demo
Target Server Type : MySQL
Target Server Version : 50650
File Encoding : 65001
Date: 02/02/2021 11:24:58
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for tbl_server
-- ----------------------------
DROP TABLE IF EXISTS `tbl_server`;
CREATE TABLE `tbl_server` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`sid` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`ip` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`port` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`isMain` int(1) DEFAULT NULL,
`canRead` int(1) DEFAULT NULL,
`canWrite` int(1) DEFAULT NULL,
`state` int(1) DEFAULT NULL,
`equalsServers` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tbl_server
-- ----------------------------
BEGIN;
INSERT INTO `tbl_server` VALUES (1, 's1', '127.0.0.1', '3305', 1, 1, 0, 1, '1,2');
COMMIT;
-- ----------------------------
-- Table structure for tbl_sharddetail
-- ----------------------------
DROP TABLE IF EXISTS `tbl_sharddetail`;
CREATE TABLE `tbl_sharddetail` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`groupId` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`serverId` int(11) DEFAULT NULL,
`idBegin` int(255) DEFAULT NULL,
`idEnd` int(255) DEFAULT NULL,
`modValue` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`shardTblName` varchar(255) COLLATE utf8_bin DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tbl_sharddetail
-- ----------------------------
BEGIN;
INSERT INTO `tbl_sharddetail` VALUES (1, 'g1', 1, 1, 50, '0', 'tbl_user_0');
INSERT INTO `tbl_sharddetail` VALUES (2, 'g1', 1, 1, 50, '0', 'tbl_user_1');
INSERT INTO `tbl_sharddetail` VALUES (3, 'g1', 2, 51, 100, '0,1', 'tbl_user');
COMMIT;
-- ----------------------------
-- Table structure for tbl_shards
-- ----------------------------
DROP TABLE IF EXISTS `tbl_shards`;
CREATE TABLE `tbl_shards` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tblName` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`idBegin` int(255) DEFAULT NULL,
`idEnd` int(255) DEFAULT NULL,
`groupId` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`modNum` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-- ----------------------------
-- Records of tbl_shards
-- ----------------------------
BEGIN;
INSERT INTO `tbl_shards` VALUES (1, 'tbl_user', 1, 100, 'g1', 2);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 操作说明
操作说明 通过id,groupId,modNum(如果值不为1,则通过切片计算,id/modNum,在detail查找到相应的服务器)查找服务器,