学会放弃

my blog is here

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Sql 2005 全文索引

Northwind示例数据库

操作其Customers

--初始化全文索引

EXEC sp_fulltext_database 'enable'

GO

 

--创建一个名为test 的全文目录

EXEC sp_fulltext_catalog 'test', 'create'

GO

 

--创建并填充全文索引

EXEC sp_fulltext_table 'Customers','create','test','PK_Customers'

EXEC sp_fulltext_column 'Customers','CompanyName','add',0x0804

EXEC sp_fulltext_table 'Customers','start_change_tracking'

EXEC sp_fulltext_table 'Customers','Start_background_updateindex'

GO

 

WAITFOR DELAY '00:00:15'

--延时后可以检索到数据

SELECT * FROM Customers WHERE CONTAINS(CompanyName,N'La')

SELECT * FROM Customers WHERE CONTAINS(CompanyName,N'Hungry')

GO

 

得到两个数据集

 

再加一列

EXEC sp_fulltext_column 'Customers','ContactName','add',0x0804

EXEC sp_fulltext_table 'Customers','start_change_tracking'

EXEC sp_fulltext_table 'Customers','Start_background_updateindex'

 

再来搜索

SELECT * FROM Customers WHERE CONTAINS(CompanyName,N'La')

or CONTAINS(ContactName,N'Elizabeth')

 


再加一个表

试验:2005支持ntext查询

select * from Employees where Notes like '%Steven%'

 

EXEC sp_fulltext_table 'Employees','create','test','PK_Employees'

EXEC sp_fulltext_column 'Employees','Notes','add',0x0804

EXEC sp_fulltext_table 'Employees','start_change_tracking'

EXEC sp_fulltext_table 'Employees','Start_background_updateindex'

GO

结果

警告: 表或索引视图'Employees' 具有类型为imagetext ntext 的全文索引列。全文更改跟踪无法跟踪对这些列执行的WRITETEXT UPDATETEXT 操作。

SELECT * FROM Employees WHERE CONTAINS(Notes,N'Steven')

 

 

posted on 2007-07-27 14:54  leohuang  阅读(444)  评论(0编辑  收藏  举报