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 ...
随机推荐
- XML的基本操作
所有 XML 文档中的文本均会被解析器解析.只有 CDATA 区段(CDATA section)中的文本会被解析器忽略.CDATA 部分中的所有内容都会被解析器忽略.CDATA 部分由 "& ...
- Chart图形 [功能帮助类] Assistant创建显示图像的标签和文件 (转载)
点击下载 Assistant.zip /// <summary> /// 类说明:Assistant /// 联系方式:361983679 /// 更新网站:[url=http://www ...
- while循环的跳出
今天在编码时突然产生一个疑问:程序中有一个while循环,循环体执行的是某个附带条件限制的操作.我现在想达到的目的是 => 条件成立,就执行操作,并跳出循环:条件不成立就跳出当次的while循环 ...
- oracle编译 失效对象方式
如果procedure 所使用的表结构发生了改变等其它情况,在相应的xxx_objects表的status字段会变为invalid状态,但是如果在调用时procedure会自动编译,grant失效对象 ...
- java web工程的错误页面的简单配置
jsp页面,本身服务器也会将该页面翻译成一个servlet页面,所以请求该页面就会有可能出现错误的情况,就会出现下面类似的页面 这样给客户看到并不友好. 1.jsp页面<%@ page %> ...
- win7下装ubuntu
需要的东西有: 1,ubuntu系统镜像,下载地址:http://www.ubuntu.com/download/desktop 选64位吧,兼容性好些. 2,空闲的大于20G硬盘空间,这个大小根据个 ...
- 桌面浏览器实现滑动翻页效果(Swiper)
还是那个号称很炫的B/S展示软件,在液晶屏上展示需要有滑动翻页的效果(在同一页面滑动切换内容,不是切换页面),最后确定使用功能很强大的Swiper类库. 具体优点可参考:http://www.chin ...
- MVVM模式应用 之的RelayCommand的使用
实现MVVM模式Command是立下了汗马功劳.当然ICommand要引用using System.Windows.Input命名空间. 比如: (1)我们在xaml页面有一个Button按钮,我们需 ...
- SVN遇到Can't convert string from 'UTF-8' to native encoding
刚配好mysql,svn co代码的时候遇到问题 svn: Can't convert string from 'UTF-8' to native encoding: svn: platform/co ...
- 不错的轮播插件flexslider
http://flexslider.woothemes.com/ $('.flexslider').flexslider({ animation:'slide', //滑动效果:翻页效果,默认为fad ...