mysql CREATE TABLE reviews (id INT(5) PRIMARY KEY NOT NULL AUTO_INCREMENT, data TEXT);
以上命令创建了一个简单的音乐专集资料库(主要是整段的文字),然后向这个表格中添加一些记录:
mysql INSERT INTO `reviews` (`id`, `data`) VALUES(1, 'Gingerboy has a new single out called Throwing Rocks. It's great!');mysql INSERT INTO `reviews` (`id`, `data`) VALUES (2, 'Hello all, I really like the new Madonna singleOne of the hottest tracks currently playing...I've been listening to it all day');mysql INSERT INTO `reviews` (`id`, `data`)VALUES (3, 'Have you heard the new band Hotter Than Hell?They have five members and they burn their instruments when they play in concerts. These guys totally rock! Like, awesome, dude!');
验证数据的正确录入:
mysqlSELECT * FROM reviews;+----+--------------------------------------------+id data+----+--------------------------------------------+1Gingerboy has a new single out called ...2Hello all, I really like the new Madon ...3 Have you heard the new band Hotter Than...+----+--------------------------------------------+4 rows in set (0.00 sec)
接下来,定义您要作为全文搜索索引的字段
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/mysql/)mysql mysql ALTER TABLE reviews ADD FULLTEXT INDEX (data);Query OK, 3 rows affected (0.21 sec)Records: 3 Duplicates: 0 Warnings: 0
使用SHOW INDEXES命令来检查索引已经被添加了:
当您拥有了数据和索引,就可以使用M 猜你喜欢