如何使用 MyISAM 引擎表创建 MySQL 表?
要创建使用 MyISAM 引擎的 MySQL 表,我们可以使用 ENGINE 命令。首先使用 CREATE 命令创建表。
mysql> create table StudentRecordWithMyISAM -> ( -> Id int, -> StudentName varchar(100), -> StudentAge int -> )ENGINE=MyISAM; Query OK, 0 rows affected (0.26 sec)
上面,我们已将 ENGINE 设为 “MyISAM”。
要检查表中显示的列数,使用 DESC 命令。
mysql> DESC StudentRecordWithMyISAM;
输出如下。
+-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | Id | int(11) | YES | | NULL | | | StudentName | varchar(100) | YES | | NULL | | | StudentAge | int(11) | YES | | NULL | | +-------------+--------------+------+-----+---------+-------+ 3 rows in set (0.00 sec)
检查表是否显示为 MyISAM。
mysql> SHOW TABLE STATUS FROM business LIKE 'StudentRecordWithMyISAM';
以下输出清楚地显示了 ENGINE 是 MyISAM。
+-------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+ | Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment | +-------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+ | studentrecordwithmyisam | MyISAM | 10 | Dynamic | 0 | 0 | 0 | 281474976710655 | 1024 | 0 | 1 | 2018-10-22 15:47:01 | 2018-10-22 15:47:02 | NULL | utf8mb4_unicode_ci | NULL | | | +-------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+ 1 row in set (0.14 sec)
检查 MyISAM 表是否存在。
mysql> SELECT TABLE_NAME, -> ENGINE -> FROM information_schema.TABLES -> WHERE TABLE_SCHEMA = 'business' and ENGINE = 'MyISAM';
输出如下。
+-------------------------+--------+ | TABLE_NAME | ENGINE | +-------------------------+--------+ | studentrecordwithmyisam | MyISAM | +-------------------------+--------+ 1 row in set (0.00 sec)
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
安卓
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP