MySQL查看和修改表的存儲引擎

  1. 查看當前支持的存儲引擎

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
| BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
| ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
| FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
| InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+

2.查看錶使用的存儲引擎

mysql> show table status from 數據庫 where name='表名' \G  #方法一
*************************** 1. row ***************************
           Name: 表名
         Engine: InnoDB  #存儲引擎類型
        Version: 10
     Row_format: Compact
           Rows: 2
 Avg_row_length: 8192
    Data_length: 16384
Max_data_length: 0
   Index_length: 0
      Data_free: 0
 Auto_increment: 3
    Create_time: 2015-07-21 10:51:48
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: 
        Comment: 
        
mysql> show create table test \G    #方法二
*************************** 1. row ***************************
       Table: test
Create Table: CREATE TABLE `test` (
  `tid` int(11) DEFAULT NULL,
  `tname` char(30) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8

3.修改表引擎方法

mysql> alter table test engine=innodb;

4.設置默認引擎

1)修改配置文件my.cnf中的 [mysqld]選項 加入 default-storage-engine=INNODB #設置innodb爲默認引擎

2)重啓mysql服務器:

#mysqladmin -u root -p shutdown

或者

#service mysqld restart


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章