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

2008-04-02 10:47:34来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

  如何在SQL中启用全文检索功能?本文将通过实例向您剖折这个问题。这是个全文索引的一个例子,首先在查询分析器中使用:www.c hinaitpower.coml1odLWyQ


  use pubs
  go www.c hinaitpower.coml1odLWyQ


  --打开数据库全文索引的支持www.c hinaitpower.coml1odLWyQ


 execute sp_fulltext_database ''enable''
 go www.c hinaitpower.coml1odLWyQ


  --建立全文目录ft_titles
  execute sp_fulltext_catalog ''ft_titles'', ''create''
  go www.c hinaitpower.coml1odLWyQ


  --为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_help titles得知
  execute sp_fulltext_table ''titles'',''create'', ''ft_titles'', ''UPKCL_titleidind''
  go www.c hinaitpower.coml1odLWyQ


  --配置全文索引列名
  exec sp_fulltext_column ''titles'', ''title'', ''add''
  go
  exec sp_fulltext_column ''titles'', ''notes'', ''add''
  go www.c hinaitpower.coml1odLWyQ


  --建立全文索引
  exec sp_fulltext_table ''titles'', ''activate''
  go www.c hinaitpower.coml1odLWyQ


  --填充全文索引目录
  exec sp_fulltext_catalog ''ft_titles'', ''start_full''
  go www.c hinaitpower.coml1odLWyQ


  --使用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

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇: SQL语句导入导出大全

下一篇: 微软未来的“灵魂”——SQL Server 2005探密