变量table_type无效,因为自MySQL 5.5.3起不赞成使用此变量。请改用default_storage_engine。以下是语法-
SET default_storage_engine = yourTableEngine;
表引擎名称可以是InnoDB或MyISAM。在这里,我们将引擎类型设置为MyISAM-
mysql> SET default_storage_engine=MyISAM; Query OK, 0 rows affected (0.00 sec)
让我们创建一个表。
mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY ); Query OK, 0 rows affected (0.40 sec)
现在检查上表的引擎类型-
mysql> SHOW TABLE STATUS WHERE Name = 'DemoTable';
这将产生以下输出-
+--------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | 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 | +--------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ | DemoTable | MyISAM | 10 | Fixed | 0 | 0 | 0 | 1970324836974591 | 1024 | 0 | 1 | 2019-05-01 22:15:03 | 2019-05-01 22:15:03 | NULL | utf8_unicode_ci | NULL | | | +--------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+ 1 row in set (0.34 sec)
查看上面的示例输出,引擎类型为MyISAM。
注–在MySQL 8.0.12版中,默认存储为InnoDB。在这里,我们仅将当前会话的存储引擎更改为MyISAM。