Chinaunix首页 | 论坛 | 博客
  • 博客访问: 445869
  • 博文数量: 750
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 4970
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-09 12:36
文章分类

全部博文(750)

文章存档

2011年(1)

2008年(749)

我的朋友
最近访客

分类:

2008-09-09 15:26:00


  全文索引的一个例子,在查询分析器中使用:
  use pubs
  go
  --打开数据库全文索引的支持
  execute sp_fulltext_database 'enable'
  go
  --建立全文目录ft_titles
  execute sp_fulltext_catalog 'ft_titles', 'create'
  go
  --为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_help titles得知
  execute 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
  
【责编:admin】

--------------------next---------------------

阅读(232) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~