更新时间:2024-04-11 GMT+08:00

MySQL 8.0是否支持全文检索

MySQL 8.0版本支持全文检索,关键字为FULLTEXT。可执行如下SQL语句测试。

  • 创建表
CREATE TABLE ARTICLE (
id int unsigned NOT NULL AUTO_INCREMENT, 
title varchar(200) DEFAULT NULL, 
content text,
PRIMARY KEY (id), 
FULLTEXT KEY title (title,content),
FULLTEXT KEY fulltext_article (title,content)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • 创建索引
    ALTER TABLE ARTICLE ADD FULLTEXT INDEX fulltext_article (title,content);
  • 查看索引
    SHOW INDEX FROM ARTICLE;