如何建立帶 InnoDB 引擎表的 MySQL 表?


要建立帶 InnoDB 引擎的表,我們可以使用 ENGINE 命令。以下查詢用於建立表。

mysql> create table EmployeeRecords
- > (
- > EmpId int,
- > EmpName varchar(100),
- > EmpAge int,
- > EmpSalary float
- > )ENGINE=INNODB;
Query OK, 0 rows affected (0.46 sec)

我們已將 ENGINE 設為上面的 INNODB。

使用 DESC 命令查看錶的完整說明。

mysql> DESC EmployeeRecords;

以下為輸出。

+-----------+--------------+------+-----+---------+-------+
| Field     | Type         | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| EmpId     | int(11)      | YES  |     | NULL    |       |
| EmpName   | varchar(100) | YES  |     | NULL    |       |
| EmpAge    | int(11)      | YES  |     | NULL    |       |
| EmpSalary | float        | YES  |     | NULL    |       |
+-----------+--------------+------+-----+---------+-------+
4 rows in set (0.05 sec)

要檢查表是否已使用 InnoDB 建立。

mysql> SHOW TABLE STATUS FROM business LIKE 'EmployeeRecords';

以下為輸出 −

+-----------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| 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 |
+-----------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| employeerecords | InnoDB | 10 | Dynamic | 0 | 0 | 16384 | 0 | 0 | 0 | NULL | 2018-10-22 15:22:01 | NULL | NULL | utf8mb4_unicode_ci | NULL | | |
+-----------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
1 row in set (0.10 sec)

在上述輸出中,“Engine”顯示為“InnoDB”。

更新於:26-6 月-2020

1K+ 瀏覽

啟動您的 職業

透過完成本課程獲得認證

開始
廣告