RainyLin-SunnyLin的专栏

未曾清贫难成人,不经打击老天真,从来英雄出炼狱,自古富贵入凡尘,醉生梦死谁成器,拓马长枪定乾坤。...

Sql 2005 全文索引

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')

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')

 
阅读更多
个人分类: Sql Server
想对作者说点什么? 我来说一句

SQL Server 2005 全文索引

2009年08月17日 91KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭