How to create a MySQL table with InnoDB engine table?


To create a table with InnoDB engine, we can use the ENGINE command. Here is the query to create a table.

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

We have set the ENGINE as INNODB above.

Check the full description about the table using the DESC command.

mysql> DESC EmployeeRecords;

The following is the output.

+-----------+--------------+------+-----+---------+-------+
| 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)

To check if the table is created with InnoDB.

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

Here is the output −

+-----------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| 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)

In the above output, the “Engine” is visible as “InnoDB”.

Updated on: 26-Jun-2020

835 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements