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

王朝mssql·作者佚名  2006-01-09
宽屏版  字体: |||超大  

如何在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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有