正文

 如何在SQL中启用全文检索功能?2007-01-30 10:18:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/Csharpsky/22968.html

分享到:

如何在SQL中启用全文检索功能?

--------------------------------------------------------------------------------
 
全文索引的一个例子,在查询分析器中使用:
use pubs
go
--打开数据库全文索引的支持
execute sp_fulltext_database 'enable'
go
--建立全文目录ft_titles
execute sp_fulltext_catalog 'ft_titles', 'create'
go
--为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_help titles得知
execute 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

阅读(2158) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册