时, MyS QL 开始支持全文索引和搜索。全文索引在 MySQ L中是一个 FUL LTEXT 类型索引。 FULL TEXT 索引用于 MyISA M表,可以在 CR EATE TABLE 时或之后使用 AL TER T ABLE 或 CRE ATE I NDEX 在 CHA R、 VAR CHAR 或 TEX T列上创建。对于大的数据库, 将数据装载到一个没有 FULL TEXT 索引的表中,然后再使用 ALT ER TA BLE (或 CRE ATE I NDEX) 创建索引,这将是非常快的。将数据装载到一个已经有 FULL TEXT 索引的表中,将是非常慢的。全文搜索通过 MA TCH() 函数完成。 m ysql> CREA TE TA BLE a rticl es(->id INT UNSI GNED AUTO_ INCRE MENT NOT N ULL P RIMAR Y KEY , -> titl e VAR CHAR( 200), ->body TEXT, -> FULLT EXT ( title ,body ) ->); Que ry OK ,0r ows a ffect ed ( s ec) mysql > INS ERT I NTO a rticl es VA LUES -> (NU LL,'M ySQL Tutor ial', 'DBM S sta nds for Da taBas e... '), -> (NUL L,'Ho w To Use M ySQL Effic ientl y',' After you went throu gha ...') , ->( NULL, 'Opti misin g MyS QL',' In th is tu toria l we will show ...') , ->( NULL, '1001 MySQ L Tri cks', ' ever run m ysqld asr oot. 2... .'), -> (NU LL,'M ySQL vs. Y ourSQ L',' In the fol lowin g dat p ariso n... '), -> (NUL L,'My SQL S ecuri ty', 'When conf igure d pro perly , MyS QL .. .'); Query OK, 6 row s aff ected ( 0 sec ) Rec ords: 6D uplic ates: 0W arnin gs: 0 mys ql> S ELECT * FR OM ar ticle s -> WH ERE M ATCH (titl e,bod y) AG AINST ('da tabas e'); +---- +---- ----- ----- ----- +---- ----- ----- ----- ----- ----- ----- ----- ---+ | id| tit le|bod y| +---- +---- ----- ----- ----- +---- ----- ----- ----- ----- ----- ----- ----- ---+ |5| MyS QL vs. You rSQ
mysql数据库中的全文检索 来自淘豆网m.daumloan.com转载请标明出处.