zoukankan      html  css  js  c++  java
  • mysql将一个表拆分成多个表(一)(转载)

    转载

    直接根据数据量进行拆分

    有一个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;

  • 相关阅读:
    Android 基础-2.0 拔打电话号码
    Android 基础-1.0 按钮4种点击事件
    Android Studio 技巧备忘
    Android Studio Mac版快捷键
    face++静态库转为动态库之二
    Podfile语法参考
    iOS 高级去水印,涂鸦去水印
    vector 用法小例子
    UltraCompare 激活
    linux 日志查询
  • 原文地址:https://www.cnblogs.com/macT/p/12055308.html
Copyright © 2011-2022 走看看