转载

直接根据数据量进行拆分

有一个5000条数据的表,要把它变成没1000条数据一个表的5等份。

假设:表名:xuesi 主键:kid
xuesi共有5000条数据,kid从1到5000自动增长
题目:将xuesi分成5个表 每个表1000条不同的数据

方法1:
create table xuesi1 select * from xuesi order by kid limit 0,1000;
create table xuesi2 select * from xuesi order by kid limit 1000,1000;
create table xuesi3 select * from xuesi order by kid limit 2000,1000;
create table xuesi4 select * from xuesi order by kid limit 3000,1000;
create table xuesi4 select * from xuesi order by kid limit 4000,1000;

以上方法 是根据大表xuesi的主键kid 创建了xuesi1,xuesi2,xuesi3,xuesi4,xuesi5 五等份的小表
不足:primary key 属性丢失

方法2:
create table xuesi1 like xuesi;
insert into xuesi1 select * from xuesi order by limit 0,1000;
create table xuesi2 like xuesi;
insert into xuesi2 select * from xuesi order by limit 1000,1000;
create table xuesi2 like xuesi;
insert into xuesi3 select * from xuesi order by limit 2000,1000;
create table xuesi3 like xuesi;
insert into xuesi4 select * from xuesi order by limit 3000,1000;
create table xuesi5 like xuesi;
insert into xuesi5 select * from xuesi order by limit 4000,1000;

最新文章

  1. JSON 的标准:双引号而非单引号!
  2. Sql--order by、desc降序、top
  3. 软件工程(FZU2015)赛季得分榜,第10回合(alpha冲刺)
  4. android wifi P2P CONNECT, INVITE和JOIN流程选择
  5. DOM--4 响应用户操作和事件(1)
  6. 调试WEB APP多设备浏览器
  7. Never-build package 'XXXX' requires always-build package 'EhLib70'
  8. hibernate--student_course_score
  9. ES2:ElasticSearch 集群配置
  10. CSS3特效----制作3D旋转导航
  11. My操作小技巧
  12. [新三板摘牌]国资企业济南华光光电去年终止拟IPO今年摘牌新三板
  13. js 图片转换base64 base64转换为file对象
  14. c# 抽象类与接口【学习笔记】
  15. Scrapy中将item字段转为简体or繁体
  16. Linux 读取 (*.xls)文件读取,使用libxls库
  17. 【实践报告】Linux基础实践一
  18. 从Encoder到Decoder实现Seq2Seq模型
  19. 部分Linux时区改为东八区的方法
  20. Matlab-9:中心差分方法解常微分算例(SOR完整版)

热门文章

  1. 4500-X验证镜像完整性
  2. Android学习02
  3. 【C语言】创建一个函数,将输入的2个数排序
  4. hadoop学习笔记(二):hdfs优点和缺点
  5. 关注Ionic底部导航按钮tabs在android情况下浮在上面的处理
  6. stl_vector复习
  7. Python web在IIS上发布方法和原理
  8. Ubuntu 17.04 apt-get 获取失败
  9. Linux学习:进入与退出系统
  10. Latin-1字符集