MySQL数据库的各种搜素引擎

一、 什么是存储引擎

MySQL中的数据用各种不同的技术存储在文件(或者内存)中。这些技术中的每一种技术都使用不同的存储机制、索引技巧、锁定水平并且最终提供广泛的不同的功能和能力。这些不同的技术以及配套的相关功能在 MySQL中被称作存储引擎(也称作表类型)。也就是说用什么方式来存储数据,每个方式就是一种表类型。

二、mysql存储引擎种类

存储引擎主要有: 1. MyIsam , 2. Mrg_Myisam, 3. Memory, 4. Blackhole, 5. CSV, 6. Performance_Schema, 7. Federated , 8.InnoDB
在mysql中,使用下面命令可以查看MySQL支持的引擎。

show engines;
mysql> show engines\G;
*************************** 1. row ***************************
Engine: CSV
Support: YES
Comment: CSV storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 2. row ***************************
Engine: InnoDB
Support: DEFAULT
Comment: Supports transactions, row-level locking, and foreign keys
Transactions: YES
XA: YES
Savepoints: YES
*************************** 3. row ***************************
Engine: MRG_MYISAM
Support: YES
Comment: Collection of identical MyISAM tables
Transactions: NO
XA: NO
Savepoints: NO
*************************** 4. row ***************************
Engine: BLACKHOLE
Support: YES
Comment: /dev/null storage engine (anything you write to it disappears)
Transactions: NO
XA: NO
Savepoints: NO
*************************** 5. row ***************************
Engine: MyISAM
Support: YES
Comment: MyISAM storage engine
Transactions: NO
XA: NO
Savepoints: NO
*************************** 6. row ***************************
Engine: FEDERATED
Support: NO
Comment: Federated MySQL storage engine
Transactions: NULL
XA: NULL
Savepoints: NULL
*************************** 7. row ***************************
Engine: PERFORMANCE_SCHEMA
Support: YES
Comment: Performance Schema
Transactions: NO
XA: NO
Savepoints: NO
*************************** 8. row ***************************
Engine: MEMORY
Support: YES
Comment: Hash based, stored in memory, useful for temporary tables
Transactions: NO
XA: NO
Savepoints: NO
具体介绍参考mysql 的存储引擎介绍这篇文章。

三、如选择改数据库引擎

方法一:
修改配置文件my.cnf,在[mysqld]后面添加default-storage-engine=InnoDB,重启服务,数据库默认的引擎修改为InnoDB
方法二:
在建表的时候指定:

 Create Table: CREATE TABLE `student` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
 `name` char(15) NOT NULL,
`age` tinyint(2) NOT NULL DEFAULT '0',
`dept` varchar(16) DEFAULT NULL,
`sex` char(2) DEFAULT NULL,
 PRIMARY KEY (`id`),
 KEY `index_dept` (`dept`(8))
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
#指定 ENGINE=InnoDB

方法三:
建表后更改

alter table table_name ENGINE = InnoDB;
例如:

alter table student ENGINE=InnoDB;

四、如何查看使用什么引擎

方法一:
show table status from database_name;
例如:

show table status from data_default\G;
show table status from mysql\G;

方法二:
show create table table_name
例如:

 show create table student\G;
 show create table mysql.time_zone_transition_type\G;

猜你喜欢

转载自blog.csdn.net/weixin_44596822/article/details/94122644