top
Loading...
實例演示在SQL數據庫中啟用全文檢索

如何在SQL中啟用全文檢索功能?本文將通過實例向你剖折這個問題。這是一個全文索引的一個例子,首先在查詢分析器中使用:

e pubsgo

打開數據庫全文索引的支持

ute sp_fulltext_database 'enable'go

建立全文目錄ft_titles

ute sp_fulltext_catalog 'ft_titles', 'create'go

為titles表建立全文索引數據元,UPKCL_titleidind是主鍵所建立的唯一索引,可由sp_help titles得知

cute sp_fulltext_table 'titles','create', 'ft_titles', 'UPKCL_titleidind'go

設置全文索引列名

exec sp_fulltext_column 'titles', 'title', 'add'goexec 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 titleswhere contains(title, '"computer Cooking"')goselect title, notes from titleswhere freetext(title, 'computer Cooking')goselect title, notes from titleswhere freetext(title, '"computer Cooking"')goselect title, notes from titleswhere contains(title, 'computer')goselect title, notes from titleswhere freetext (*, 'computer')go
作者:http://www.zhujiangroad.com
來源:http://www.zhujiangroad.com
北斗有巢氏 有巢氏北斗