26.笔记 MySQL学习——MySQL的表选项

来源:互联网 发布:win10磁盘碎片整理软件 编辑:程序博客网 时间:2024/06/06 05:31

26.笔记 MySQL学习——MySQL的表选项

在CREATE TABLE语句中的右括号之后加上一个或多个表选项。

例如:

CREATE TABLE mytbl ( … ) ENGINE = MEMORY;

实际执行如下:

mysql> create table t (i int) engine=archive;

Query OK, 0 rows affected (0.00 sec)

这样可以选择表的存储引擎。

查看表属于哪种存储引擎

mysql> show create table t;

+-------+---------------------------------------------------------------------------------------+

| Table | Create Table                                                                         |

+-------+---------------------------------------------------------------------------------------+

| t    | CREATE TABLE `t` (

  `i`int(11) DEFAULT NULL

) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 |

+-------+---------------------------------------------------------------------------------------+

1 row in set (0.01 sec)

修改表的存储特性

mysql> alter table t engine = InnoDB;

Query OK, 0 rows affected (0.04 sec)

Records: 0 Duplicates: 0  Warnings: 0

 

mysql> show create table t;

+-------+--------------------------------------------------------------------------------------+

| Table | Create Table                                                                        |

+-------+--------------------------------------------------------------------------------------+

| t    | CREATE TABLE `t` (

  `i`int(11) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1 |

+-------+--------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

 

 

 

 

 

原创粉丝点击