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

来源:互联网 发布:幼儿园手指数算法视频 编辑:程序博客网 时间:2024/04/28 07:43
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
  如何在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

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击