标签:
MySQL在创建新表时,如果不指定存储引擎,那么系统就会使用默认存储引擎。MySQL5.5之前版本的默认存储引擎为MyISAM,5.5版本后改为了InnoDB。
1. 修改默认存储引擎:
例:修改默认存储引擎为INNODB
在配置文件my.ini(Windows)或my.cnf(Linux)中的[mysqld]下加入:default-storage-engine=INNODB;
2. 查看当前的默认存储引擎:
(1) show variables like ‘default_storage_engine‘;
mysql> show variables like ‘default_storage_engine‘;
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| default_storage_engine | InnoDB |
+------------------------+--------+
(2) show engines; 字段Support值为DEFAULT的表示为默认存储引擎;
mysql> show engines\G
*************************** 1. row ***************************
Engine: MyISAM
Support: YES
Comment: MyISAM storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 2. row ***************************
Engine: PERFORMANCE_SCHEMA
Support: YES
Comment: Performance Schema
Transactions: NO
XA: NO
Savepoints: NO
*************************** 3. row ***************************
Engine: CSV
Support: YES
Comment: CSV storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 4. row ***************************
Engine: MRG_MYISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 5. row ***************************
Engine: InnoDB
Support: DEFAULT
Comment: Supports transactions, row-level locking, and foreign keys
Transactions: YES
XA: YES
Savepoints: YES
*************************** 6. row ***************************
Engine: MEMORY
Support: YES
Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
XA: NO
Savepoints: NO
3. 查询当前数据库支持的存储引擎
show engines;
4. 在创建新表时,通过增加ENGINE关键字设置表的存储引擎。
5. 使用ALTER TABLE语句,将一个已存在的表修改成其他的存储引擎。
例:将表的存储引擎修改为INNODB
ALTER TABLE tbl_name ENGINE = INNODB;
标签:
原文地址:http://www.cnblogs.com/bloveice0915/p/5430272.html