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 表的更多相关文章

  1. 14.6.1 Creating InnoDB Tables 创建InnoDB 表:

    14.6.1 Creating InnoDB Tables 创建InnoDB 表: 创建一个InnoDB 表,使用CREATE TABLE 语句,你不需要指定 ENGINE=InnoDB子句 如果In ...

  2. 14.8.4 Moving or Copying InnoDB Tables to Another Machine 移动或者拷贝 InnoDB 表到另外机器

    14.8.4 Moving or Copying InnoDB Tables to Another Machine 移动或者拷贝 InnoDB 表到另外机器 这个章节描述技术关于移动或者复制一些或者所 ...

  3. 14.8.3 Physical Row Structure of InnoDB Tables InnoDB 表的物理行结构

    14.8.3 Physical Row Structure of InnoDB Tables InnoDB 表的物理行结构 一个InnoDB 表的物理行结构取决于在创建表指定的行格式 默认, Inno ...

  4. 14.6.7?Limits on InnoDB Tables InnoDB 表的限制

    14.6.7?Limits on InnoDB Tables InnoDB 表的限制 警告: 不要把MySQL system tables 从MyISAM 到InnoDB 表. 这是不支持的操作,如果 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小

    14.7.1 Resizing the InnoDB System Tablespace InnoDB 系统表空间大小 这个章节描述如何增加或者减少 InnoDB 系统表空间的大小 增加InnoDB ...

  9. 14.6.11 Configuring Optimizer Statistics for InnoDB 配置优化统计信息用于InnoDB

    14.6.11 Configuring Optimizer Statistics for InnoDB 配置优化统计信息用于InnoDB 14.6.11.1 Configuring Persisten ...

随机推荐

  1. oracle学习----访问路径

    什么是访问路径?表扫描数据的时候使用了什么方式,这个方式就是访问路径 1.全表扫描TABLE ACCESS FULL 全表扫描,多块读,等待事件:db file scattered read 如果是并 ...

  2. Java基础知识强化之集合框架笔记54:Map集合之HashMap集合(HashMap<String,String>)的案例

    1. HashMap集合 HashMap集合(HashMap<String,String>)的案例 2. 代码示例: package cn.itcast_02; import java.u ...

  3. Java基础知识强化之网络编程笔记04:UDP之发送端的数据来自于键盘录入案例

    1. 数据来自于键盘录入 键盘录入数据要自己控制录入结束. 2. 代码实现: (1)发送端: package com.himi.updDemo1; import java.io.IOException ...

  4. awk用法举例

    awk文本分割输出工具(按列输出工具) awk [options] ' PATTERN { action } ' file1, file2, ... 内置变量: FS:field separator, ...

  5. web程序记录当前在线人数

    在页面上显示当前在线人数 效果: 1.Global.asax文件: <%@ Application Language="C#" %><%@ Import Name ...

  6. mvc5 + ef6 + autofac搭建项目(四).1视屏上传生成截图

    即上一篇中上传涉及到的 一个视频生成截图的问题,这个很简单,这是上一篇中的代码片段 #region 视频上传,生成默认展示图片(自动剪切) try { string fileSavePath = Da ...

  7. Hibernate session flush

    最近做项目时,用到了hibernnate,批量删除10000条数据时,删除时前台将id传到后台,用in匹配去删除,页面直接卡死. 解决方法,将传过来的10000条id分批删除,每删除五百条后,调用ge ...

  8. Android更新UI的两种方法——handler与runOnUiThread()

    在Android开发过程中,常需要更新界面的UI.而更新UI是要主线程来更新的,即UI线程更新.如果在主线线程之外的线程中直接更新页面 显示常会报错.抛出异常:android.view.ViewRoo ...

  9. bootstrap轮播组件,大屏幕图片居中效果

    在慕课网学习bootstrap轮播组件的时候,了解到轮播的图片都放在了类名为item下的img中 视频中老师对图片自适应采用给图片img设置width=100%完成,然而这样自适应处理图片在不同屏幕中 ...

  10. 11-17的学习总结(DOMfirstday)

    HTML: 超文本标记语言,专门定义网页内容的语言 XHTML: 严格的HTML标准 DHTML: 所有实现网页动态效果技术的统称 XML: 可扩展的标记语言,标签都是自定义的 XML语法和HTML语 ...