WEB开发网
开发学院数据库MySQL 教你怎样在MySQL中提高全文搜索效率 阅读

教你怎样在MySQL中提高全文搜索效率

 2007-02-14 10:54:59 来源:WEB开发网   
核心提示: mysql> SELECT * FROM reviews;+++| id | data |+++|1 | Gingerboy has a new single out called ...||2 | Hello all, I really like the new Madon ...
  mysql> SELECT * FROM reviews;
  +----+--------------------------------------------+
  | id | data                    |
  +----+--------------------------------------------+
  | 1 | Gingerboy has a new single out called ... |
  | 2 | Hello all, I really like the new Madon ... |
  | 3 | Have you heard the new band Hotter Than... |
  +----+--------------------------------------------+
  3 rows in set (0.00 sec)

2、定义全文搜索字段

接下来,定义您要作为全文搜索索引的字段:

  mysql> ALTER TABLE reviews ADD FULLTEXT INDEX (data);
  Query OK, 3 rows affected (0.21 sec)
  Records: 3 Duplicates: 0 Warnings: 0

使用SHOW INDEXES命令来检查索引已经被添加了:

  mysql> SHOW INDEXES FROM reviews;
  +---------+---------------+--------+------+------------+---------+
  | Table  | Column_name  | Packed | Null | Index_type | Comment |
  ----------+---------------+--------+------+------------+---------+
  | reviews | id      | NULL  |   | BTREE   |     |
  | reviews | data     | NULL  | YES | FULLTEXT  |     |
  +---------+---------------+--------+------+------------+---------+
  2 rows in set (0.01 sec)

| 2 |

+----+

2 rows in set (0.00 sec)

Tags:怎样 MySQL 提高

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接