实现mysql分表、查询,步骤如下:
1、其中ebd202101、ebd202102、ebd202103为相同表结构的物理表,用于分表存储大数据量数据
CREATE TABLE `ebd202101` (
`bill_id` INT (10) UNSIGNED NOT NULL,
`suborder_id` text NOT NULL,
`price` INT (10) UNSIGNED NOT NULL,
PRIMARY KEY (`bill_id`)
) ENGINE = MyISAM DEFAULT CHARSET = latin1;
CREATE TABLE `ebd202102` (
`bill_id` INT (10) UNSIGNED NOT NULL,
`suborder_id` text NOT NULL,
`price` INT (10) UNSIGNED NOT NULL,
PRIMARY KEY (`bill_id`)
) ENGINE = MyISAM DEFAULT CHARSET = latin1;
CREATE TABLE `ebd202103` (
`bill_id` INT (10) UNSIGNED NOT NULL,
`suborder_id` text NOT NULL,
`price` INT (10) UNSIGNED NOT NULL,
PRIMARY KEY (`bill_id`)
) ENGINE = MyISAM DEFAULT CHARSET = latin1;
2、ebd用于索引ebd202101、ebd202102、ebd202103
CREATE TABLE `ebd` (
`bill_id` INT (10) UNSIGNED NOT NULL,
`suborder_id` text NOT NULL,
`price` INT (10) UNSIGNED NOT NULL,
PRIMARY KEY (`bill_id`)
) ENGINE = MRG_MyISAM DEFAULT CHARSET = latin1
UNION
= (
`ebd202101`,
`ebd202102`,
`ebd202103`
);
3、查询验证
4、条件查询验证