14.8.1 Creating InnoDB Tables 创建InnoDB 表
14.8.1 Creating InnoDB Tables 创建InnoDB 表 创建一个InnoDB表,使用CREATE TABLE 语句,你不需要指定ENGINE=InnoDB 子句 如果InnoDB 是定义为默认的存储引擎,在MySQL 5.5是默认为InnoDB. 你仍旧可以使用 ENGINE=InnoDB clause 如果你计划使用mysqldump或者复制 来重现CREATE TABLE 在一个server上 那个server 默认不是InnoDB 存储引擎 -- Default storage engine = InnoDB.
CREATE TABLE t1 (a INT, b CHAR (20), PRIMARY KEY (a)); -- Backward-compatible with older MySQL.
CREATE TABLE t2 (a INT, b CHAR (20), PRIMARY KEY (a)) ENGINE=InnoDB; 在一个InnoDB 表和他的索引可以创建在系统表空间或者一个 file-per-table tablespace. 当 innodb_file_per_table 启用时,一个InnoDB 表时隐式的创建在一个单独的 file-per-table tablespace. 相反,当innodb_file_per_table is disabled, 一个InnoDB 表时隐式的创建在系统表空间。 当你创建一个InnoDB 表,MySQL 创建一个 .frm file 在一个数据库目录在MySQL data directory.目录下。 一个.ibd文件也会被创建 一个表创建在 system tablespace 是创建在存在的system tablespace ibdata files. 在内部, InnoDB 增加一个条目对于每个表到InnoDB 的数据字典。 条目包含数据库名字 比如,如果表t1是创建在test数据库下, 数据目录条目是'test/t1'. 这意味着你能创建相同的名字的表在不同的数据库,表名字在InnoDB内部不冲突 mysql> SHOW TABLE STATUS FROM test LIKE 't%' \G;
*************************** 1. row ***************************
Name: t1
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 0
Avg_row_length: 0
Data_length: 16384
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: NULL
Create_time: 2015-03-16 16:26:52
Update_time: NULL
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec) 在这个状态输出,你可以看到 表t1的hang格式属性是 Compact 尽管设置是好的对于基本的实验,使用动态或者压缩行格式来利用InnoDB的功能 比如表压缩和off-page storage 用于long列的值 使用那些行格式需要innodb_file_per_table 启用 mysql> SHOW TABLE STATUS FROM zjzc like 'Client'\G;
*************************** 1. row ***************************
Name: Client
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 13244
Avg_row_length: 436
Data_length: 5783552
Max_data_length: 0
Index_length: 3620864
Data_free: 3145728
Auto_increment: 13778
Create_time: 2016-10-28 09:46:59
Update_time: NULL
Check_time: NULL
Collation: utf8_general_ci
Checksum: NULL
Create_options:
Comment: 用户表 1 row in set (0.00 sec) ERROR:
No query specified SET GLOBAL innodb_file_per_table=1;
SET GLOBAL innodb_file_format=barracuda;
CREATE TABLE t3 (a INT, b CHAR (20), PRIMARY KEY (a)) ROW_FORMAT=DYNAMIC;
CREATE TABLE t4 (a INT, b CHAR (20), PRIMARY KEY (a)) ROW_FORMAT=COMPRESSED; Defining a Primary Key for InnoDB Tables 定义一个主键在InnoDB 表上 1.总是设置一个主键对于每个InnoDB表,指定列或者多列 2. 被用于最重要的查询 3.永远不会是空的 4.不会有重复值 5.很少改动一旦插入后 例如, 在一个表包含信息关于people, 你不能创建一个主键在(firstname, lastname) 因为不止一个人有相同的名字, 有些人last name是空白的,有些人会改变它们的名字。 有这么多的约束, 没有一个明显的列来使用作为主键。 因此你可以创建一个数据列ID 来作为主键,你可以定义一个自增列
14.8.1 Creating InnoDB Tables 创建InnoDB 表的更多相关文章
- 14.6.1 Creating InnoDB Tables 创建InnoDB 表:
14.6.1 Creating InnoDB Tables 创建InnoDB 表: 创建一个InnoDB 表,使用CREATE TABLE 语句,你不需要指定 ENGINE=InnoDB子句 如果In ...
- 14.8.4 Moving or Copying InnoDB Tables to Another Machine 移动或者拷贝 InnoDB 表到另外机器
14.8.4 Moving or Copying InnoDB Tables to Another Machine 移动或者拷贝 InnoDB 表到另外机器 这个章节描述技术关于移动或者复制一些或者所 ...
- 14.8.3 Physical Row Structure of InnoDB Tables InnoDB 表的物理行结构
14.8.3 Physical Row Structure of InnoDB Tables InnoDB 表的物理行结构 一个InnoDB 表的物理行结构取决于在创建表指定的行格式 默认, Inno ...
- 14.6.7?Limits on InnoDB Tables InnoDB 表的限制
14.6.7?Limits on InnoDB Tables InnoDB 表的限制 警告: 不要把MySQL system tables 从MyISAM 到InnoDB 表. 这是不支持的操作,如果 ...
- 14.6.2 Moving or Copying InnoDB Tables to Another Machine 移动或者copy InnoDB 表到另外的机器
14.6.2 Moving or Copying InnoDB Tables to Another Machine 移动或者copy InnoDB 表到另外的机器 这个章节描述技术关于移动或者copy ...
- 14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用
14.8.2 Role of the .frm File for InnoDB Tables InnoDB 表得到 .frm文件的作用 Vsftp:/data01/mysql/zjzc# ls -lt ...
- 14.2.5.1 Role of the .frm File for InnoDB Tables InnoDB .frm文件的作用
14.2.5.1 Role of the .frm File for InnoDB Tables: 14.2.5.1 Role of the .frm File for InnoDB Tables I ...
- 14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小
14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小 这个章节描述如何增加或者减少 InnoDB 系统表空间的大小 增加InnoDB ...
- 14.6.11 Configuring Optimizer Statistics for InnoDB 配置优化统计信息用于InnoDB
14.6.11 Configuring Optimizer Statistics for InnoDB 配置优化统计信息用于InnoDB 14.6.11.1 Configuring Persisten ...
随机推荐
- docker build lnmp(未完成。。。)
docker pull centos # 拉取镜像到本地 docker run -i -t -p 8000:80 --name=centosDev centos cat /etc/redhat-rel ...
- js跨浏览器事件对象、事件处理程序
项目中有时候会不用jquery这么好用的框架,需要自己封装一些事件对象和事件处理程序,像封装AJAX那样:这里面考虑最多的还是浏览器的兼容问题,原生js封装如下:var EventUtil={ //节 ...
- 给右键 添加dos命令
reg add "HKEY_CURRENT_USER\Console" /v "ScreenBufferSize" /t REG_DWORD /d 655361 ...
- 深入理解shared pool共享池之library cache的library cache pin系列三
关于library cache相关的LATCH非常多,名称差不多,我相信一些人对这些概念还是有些晕,我之前也有些晕,希望此文可以对这些概念有个更为清晰的理解,本文主要学习library cache p ...
- 如何写类库方法、属性等的注释,才能在其他地方调用dll文件时,在代码里出现智能提示?
我的本意是想整理下以往写过的代码库,给自己的代码增加复用性.一段时间后,可能自己对写过的代码是什么含义会忘掉,或者别人看自己的代码, 增加可懂性的考虑,决定要添加注释.(好像语句不通:)可是发现,在其 ...
- 支持H5的一般设置
1.因为IE8既不支持HTML5也不支持CSS3 Media,所以我们需要加载两个JS文件,来保证我们的代码实现兼容效果: <script src="https://oss.maxcd ...
- C语言的预处理命令
C语言编译器处理时经过的第一个步骤是预处理,就是从.c文件处理为.i文件.在预处理时编译器做了一些展开替换的处理. 1>头文件展开,即将#include "stdio.h"类 ...
- 练习2 E题 - 求奇数的乘积
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description 给你n ...
- BootStrap Progressbar 实现大文件上传的进度条
1.首先实现大文件上传,如果是几兆或者几十兆的文件就用基本的上传方式就可以了,但是如果是大文件上传的话最好是用分片上传的方式.我这里主要是使用在客户端进行分片读取到服务器段,然后保存,到了服务器段读取 ...
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...