ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## sql ``` create database test; -- 测试数据库 -- 快递订单表 DROP TABLE IF EXISTS `express`; CREATE TABLE `express` ( `id` int(30) NOT NULL AUTO_INCREMENT, `uid` char(100) NOT NULL COMMENT '用户id', `p_from` char(50) NOT NULL COMMENT '发件人', `p_to` char(50) CHARACTER SET utf8 NOT NULL COMMENT '收件人', `is_receive` int(1) NOT NULL DEFAULT '0' COMMENT '是否收件 0否 1收', `create_time` int(10) NOT NULL COMMENT '创建时间戳', PRIMARY KEY (`id`), KEY `uid` (`uid`) ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; --- 轨迹表 CREATE TABLE `track` ( `id` int(255) NOT NULL AUTO_INCREMENT, `y` float(10,0) DEFAULT NULL COMMENT 'y座标', `x` float(10,0) DEFAULT NULL COMMENT 'x座标', `express_id` int(22) DEFAULT NULL COMMENT '单号', PRIMARY KEY (`id`), KEY `order_number` (`express_id`) ) ENGINE=MyISAM AUTO_INCREMENT=2163031 DEFAULT CHARSET=latin1 COMMENT=' 轨迹表'; -- 添加测试数据 create procedure add_test_data() begin declare num int; declare order_number int; declare track_num int; declare track_while int; set num=1; while num <= 1000000 do insert into express(uid, p_from, p_to, is_receive, create_time) values(replace(uuid(), '-', ''), CONCAT('from_', floor(rand()*1000)), CONCAT('to_', floor(rand()*1000)),0, UNIX_TIMESTAMP(NOW())); set num=num+1; set track_while = floor(rand() * 10); set track_num = 1; while track_num <= track_while do INSERT INTO `test`.`track` ( `y`, `x`, `express_id`) VALUES (rand()*rand()*100, rand()*rand()*100, (select max(id)from express)); set track_num = track_num + 1; end while; end while; end; -- 导入 call add_test_data(); ``` 1000000 数字更具自己需求修改