扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:赛迪网技术社区 来源:赛迪网技术社区 2007年9月12日
关键字: SQL 数据库 检索 SQL Server
这是一个全文索引的一个例子,首先在查询分析器中使用:
e pubs go |
打开数据库全文索引的支持
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' 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 |
濠碘€冲€归悘澶愬箖閵娾晜濮滈悽顖涚摃閹烩晠宕氶崶鈺傜暠闁诡垰鍘栫花锛勬喆椤ゅ弧濡澘妫楅悡娆撳嫉閳ь剟寮0渚€鐛撻柛婵呮缁楀矂骞庨埀顒勫嫉椤栨瑤绻嗛柟顓у灲缁辨繈鏌囬敐鍕杽閻犱降鍨藉Σ鍕嚊閹跺鈧﹦绱旈幋鐐参楅柡鍫灦閸嬫牗绂掔捄铏规闁哄嫷鍨遍崑宥夋儍閸曨剚浠樺ù锝嗗▕閳ь剚鏌ㄧ欢鐐寸▕鐎b晝顏遍柕鍡嫹