您的位置:首页 > 数据库

如何在SQL中启用全文检索功能?(实例)

2008-04-27 00:09 483 查看
如何在SQL中启全文检索功能

--------------------------------------------------------------------------------

全文索引的一个例子,在查询分析器中使用:
usepubs
go
--打开全文索引的支持
executesp_fulltext_database'enable'
go
--建立全文目录ft_titles
executesp_fulltext_catalog'ft_titles','create'
go
--为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_helptitles得知
executesp_fulltext_table'titles','create','ft_titles','UPKCL_titleidind'
go
--设置全文索引列名
execsp_fulltext_column'titles','title','add'
go
execsp_fulltext_column'titles','notes','add'
go
--建立全文索引
execsp_fulltext_table'titles','activate'
go
--填充全文索引目录
execsp_fulltext_catalog'ft_titles','start_full'
go
--使用contains和freetext
selecttitle,notesfromtitles
wherecontains(title,'"computerCooking"')
go
selecttitle,notesfromtitles
wherefreetext(title,'computerCooking')
go
selecttitle,notesfromtitles
wherefreetext(title,'"computerCooking"')
go
selecttitle,notesfromtitles
wherecontains(title,'computer')
go
selecttitle,notesfromtitles
wherefreetext(*,'computer')
go
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: