请联系我们

实例演示在SQL数据库中启用全文检索

来源: 数据库 SQL Server |  作者: 不详 |  发布: 2009-7-08 10:09


这是一个全文索引的一个例子,首先在查询分析器中使用:

e pubs

 go

打开数据库全文索引的支持

ute sp_fulltext_database 'enable'

 go

建立全文目录ft_titles

ute sp_fulltext_catalog 'ft_titles', 'create'

go

为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_help titles得知

cute sp_fulltext_table 'titles','create', 'ft_titles', 'UPKCL_titleidind'

go

设置全文索引列名

 exec sp_fulltext_column 'titles', 'title', 'add'

go

exec sp_fulltext_column 'titles', 'notes', 'add'

go

建立全文索引

 exec sp_fulltext_table 'titles', 'activate'

go

填充全文索引目录

exec sp_fulltext_catalog 'ft_titles', 'start_full'

go

使用contains和freetext

select title, notes from titles

where contains(title, '"computer Cooking"')

go

select title, notes from titles

where freetext(title, 'computer Cooking')

go

select title, notes from titles

where freetext(title, '"computer Cooking"')

go

select title, notes from titles

where contains(title, 'computer')

go

select title, notes from titles

where freetext (*, 'computer')

go

(责任编辑:铭铭 mingming_ky@126.com TEL:(010)68476636)


* 部分内容来源于网络,版权属原作者所有,转载请注明来源。
打印 | 收藏此页 |  推荐给好友 | 举报