mysql单个表拆分成多个表

一.横向拆分

create table 新表的名称 select * from 被拆分的表 order by id  limit int1,int2

int1为其实位置,int2为几条

注意:这样拆分后主键会失效手动让其主键生效即可所有要执行

alter table 新表的名称 modify 主键字段 int primary key auto_increment

二.纵向拆分

create table 新表的名称 select 需保留的字段 from 被拆分的表 

拆分后原表都要保存

主要是把经常查的数据放在一个表里,不经常查的数据不做处理

posted @ 2019-10-25 16:22  小小咸鱼YwY  阅读(2040)  评论(0编辑  收藏  举报