http://www.cnblogs.com/alvinyue/archive/2011/06/21/2085972.html
http://www.cnblogs.com/lyhabc/articles/3254782.html
本章介绍在SQL Server 2008 R2 下的全文索引,它能够对数据中的字符类型列(如varchar、text等类型)进行索引,并通过索引实现全文搜索查询。首先对比简单介绍一下常规索引和全文索引的区别,如下图:
OK,下面我们就利用SQL Server 提供的存储过程来建立一个全文索引,具体步骤为:
(1)启动数据库的全文处理功能(sp_fulltext_datebase); (2)建立全文目录(sp_fulltext_catalog); (3)在全文目录中注册需要全文索引的表(sp_fulltext_table); (4)指出表中需要全文检索的列名(sp_fulltext_column) (5)为表创建全文索引(sp_fulltext_table); (6)填充全文索引(sp_fulltext_catalog)。
接下来用实例一步步演示:
接下来用实例一步步演示:
use DBFullText
-- 建表 createtable Student ( id intprimarykeyidentity(1,1) notnull, name nvarchar(30) null, familyAddress nvarchar(100) null, schoolAddress nvarchar(100) null )
--插入一些数据 insertinto Student values(\'SAVEA\',\'187 Suffolk Ln.\',\'1900 Oak St.\') insertinto Student values(\'VICTE\',\'2, rue du Commerce\',\'23 Tsawassen Blvd.\') insertinto Student values(\'BLONP\',\'24, place Kléber\',\'25, rue Lauriston\') insertinto Student values(\'PARIS\',\'265, boulevard Charonne\',\'2732 Baker Blvd.\') insertinto Student values(\'OLDWO\',\'2743 Bering St.\',\'2817 Milton Dr.\') insertinto Student values(\'WANDK\',\'Adenauerallee 900\',\'Åkergatan 24\') insertinto Student values(\'BERGS\',\'Berguvsvägen 8\',\'Carrera 22 con Ave. Carlos Soublette #8-35\') insertinto Student values(\'SANTG\',\'Carrera 52 con Ave. Bolívar #65-98 Llano Largo\',\'Erling Skakkes gate 78\') insertinto Student values(\'OCEAN\',\'Grenzacherweg 237\',\'Jardim das rosas n. 32\') insertinto Student values(\'LEHMS\',\'Sierras de Granada 9993\',\'Via Ludovico il Moro 22\') insertinto Student values(\'SIMOB\',\'South House 300 Queensbridge\',\'P.O. Box 555\')
--检查 DBFullText 是否支持全文索引,如果不支持全文索引,则使用sp_fulltext_datebase打开该功能 if (selectdatabaseproperty (\'DBFullText
-- 建表 createtable Student ( id intprimarykeyidentity(1,1) notnull, name nvarchar(30) null, familyAddress nvarchar(100) null, schoolAddress nvarchar(100) null )
--插入一些数据 insertinto Student values(\'SAVEA\',\'187 Suffolk Ln.\',\'1900 Oak St.\') insertinto Student values(\'VICTE\',\'2, rue du Commerce\',\'23 Tsawassen Blvd.\') insertinto Student values(\'BLONP\',\'24, place Kléber\',\'25, rue Lauriston\') insertinto Student values(\'PARIS\',\'265, boulevard Charonne\',\'2732 Baker Blvd.\') insertinto Student values(\'OLDWO\',\'2743 Bering St.\',\'2817 Milton Dr.\') insertinto Student values(\'WANDK\',\'Adenauerallee 900\',\'Åkergatan 24\') insertinto Student values(\'BERGS\',\'Berguvsvägen 8\',\'Carrera 22 con Ave. Carlos Soublette #8-35\') insertinto Student values(\'SANTG\',\'Carrera 52 con Ave. Bolívar #65-98 Llano Largo\',\'Erling Skakkes gate 78\') insertinto Student values(\'OCEAN\',\'Grenzacherweg 237\',\'Jardim das rosas n. 32\') insertinto Student values(\'LEHMS\',\'Sierras de Granada 9993\',\'Via Ludovico il Moro 22\') insertinto Student values(\'SIMOB\',\'South House 300 Queensbridge\',\'P.O. Box 555\')
--检查 DBFullText 是否支持全文索引,如果不支持全文索引,则使用sp_fulltext_datebase打开该功能 if (selectdatabaseproperty (\'DBFullText