程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> 實例演示在MSSQL中啟用全文檢索

實例演示在MSSQL中啟用全文檢索

編輯:關於SqlServer
本文將通過實例向你剖折這個問題。這是一個全文索引的一個例子,首先在查詢分析器中使用: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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved