mysql分表
2017-01-17 20:04
405 查看
1、水平分表 创建结构相同的N个表 create table student_0 ( id int not null auto_increment, name varchar(12), primary key (id) ); create table student_1 ( id int not null auto_increment, name varchar(12), primary key (id) ); create table student_2 ( id int not null auto_increment, name varchar(12), primary key (id) ); create table student_id ( id int not null auto_increment, primary key (id) ); //伪代码 $tableList = array( 'student_0', 'student_1', 'student_2' ); $tableNums = count($tableList); $sqlId = "insert into student_id values(null)"; $stuId = last_insert_id(); $tableName = $tableList[$stuId % $tableNums]; $sql = "insert into {$tableName} values({$stuId}, '测试')"; 2、merge,mrg_myisam存储引擎 mysql提供一个可以将多个结构相同的myisam表,合并到一起的存储引擎。 3、垂直分表 表中存在多个字段,将常用字段和非常用字段分别存到两张或以上的表中, 主要目的,减少每条记录的长度。 比如学生表: 基础信息表student_base 额外信息表student_extra 基础表与额外表之间通过ID来对应。 (*水平分表现在用mysql自带的partition已经很好解决了)
相关文章推荐
- mysql 1449 : The user specified as a definer (\'root\'@\'%\') does not exist 解决方法
- mysql优化概述
- mysql优化概述2
- mysql编码问题
- 在控制台远程连接mysql数据库时,出现ERROR 2049 (HY000)错误
- mysql中GROUP_CONCAT的使用
- mysql非主键自增长
- mysql数据库的优化
- mysql5.5以上my.ini中设置字符集
- mysql定位慢查询
- mysql5.5以上开启慢查询
- mysql索引
- mysql数据库的主从配置读写分离
- Network Monitor 查询命令和MySQL命令
- mysql的binary、char、varchar区别
- MySQL与网页进行数据传递(下)
- Windows下MySql5.7.17更改密码时出错“ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’"
- Mysql创建用户表并利用存储过程添加100万条随机用户数据
- 一.Mysql主从复制配置
- MySQL-Join