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. 微信分组群发45028,微信分组群发has no masssend quota hint

    微信分组群发45028,微信分组群发has no masssend quota hint >>>>>>>>>>>>>> ...

  2. Android 指定日期时间执行任务的Timer

    放上一个指定详细日期及时间的timer public class MainActivity extends Activity { private Handler handler = new Handl ...

  3. 还原或删除sql server 2008数据库时,经常烩出现: “因为数据库正在使用,所以无法获得对数据库的独占访问权”,终解决方案

    还原或删除sql server 2008数据库时,经常烩出现: “因为数据库正在使用,所以无法获得对数据库的独占访问权”,终解决方案如下 关键SQL语句: ALTER DATABASE [dateba ...

  4. 简单登录案例(SharedPreferences存储账户信息)&联网请求图片并下载到SD卡(文件外部存储)

    新人刚学习Android两周,写一个随笔算是对两周学习成果的巩固,不足之处欢迎各位建议和完善. 这次写的是一个简单登录案例,大概功能如下: 注册的账户信息用SharedPreferences存储: 登 ...

  5. pom.xml中<dependency>

    当想下载jar包时,需要在pom.xml追加<dependency>即可. 通过如下餐叙: 如下图 http://mvnrepository.com/artifact/cglib/cgli ...

  6. spring配置文件中属性mappingLocations、mappingDirectoryLocations

    http://blog.csdn.net/vacblog/article/details/7774173

  7. ios专题 - CocoaPods - 安装

    职业走得很累,停下来,温故技术.顺便开始我得ios博客文章. [原创]http://www.cnblogs.com/luoguoqiang1985 安装 第一步:执行以下命令 sudo gem ins ...

  8. Python:模块引用

    #!/usr/bin/python3 #Filename function.py #导入模块 import sys #导入function.py#function.py 文件import functi ...

  9. 网络基础---OSI 模型与TCP/IP

    一.网络的演进: 1.简单的联接:1960's ------------ 1970's    Host Network 六十至七十年代,网络的概念主要是主机架构的低速串行联接,提供应用程序执行.远程打 ...

  10. 网站访问架构cdn与负载均衡

    曾经见到知乎上有人问“为什么像facebook这类的网站需要上千个工程师维护?”,下面的回答多种多样,但总结起来就是:一个高性能的web系统需 要从无数个角度去考虑他,大到服务器的布局,小到软件中某个 ...