Home > Database > Mysql Tutorial > SQL_Server全文索引的用法解析

SQL_Server全文索引的用法解析

WBOY
Release: 2016-06-07 16:18:42
Original
1278 people have browsed it

SQL Server全文索引相信大家都有一定的了解,下面就为您介绍SQL Server全文索引的用法及相关的语句,希望可以让您对SQL Server全文索引能有更深的认识 复制代码 代码如下: --1、为数据库启用SQL Server全文索引 EXEC sp_fulltext_database 'enable' --2、创

SQL Server全文索引相信大家都有一定的了解,下面就为您介绍SQL Server全文索引的用法及相关的语句,希望可以让您对SQL Server全文索引能有更深的认识

 

复制代码 代码如下:


--1、为数据库启用SQL Server全文索引
EXEC sp_fulltext_database 'enable'

--2、创建全文目录
--(此处若出错“未安装全文搜索或无法加载某一全文组件”,,则可能是未启动或未安装此服务)
EXEC sp_fulltext_catalog 'Ask91Fable', 'create', 'D:Data2005Ask_91_Index'

--3、指定要进行全文搜索的表
--(可能出错“...全文搜索键必须是唯一的、不可为空的、单列的索引,并且该索引不是离线的...”)
--(这个表必须有一个唯一索引[主键是可以的],)

EXEC sp_fulltext_table 'Asks', 'create', 'Ask91Fable', 'PK_Ask'--唯一索引名称

--4、向全文目录中添加列
EXEC sp_fulltext_column 'Asks', 'Subject', 'add'
EXEC sp_fulltext_column 'Asks', 'Detail', 'add'

--5、激活全文目录
EXEC sp_fulltext_table 'Asks', 'activate'

--填充
EXEC sp_fulltext_table 'Asks', 'start_full'--完全填充
--EXEC sp_fulltext_table 'Asks', 'start_incremental'--增量填充

--重建(重建之后应该完全填充)
--EXEC sp_fulltext_catalog 'Ask91Fable', 'rebuild'

--调用(100万数据,)
--SELECT TOP 1 * FROM Asks

SELECT ID FROM Asks WHERE Subject LIKE '%NET小结%' OR Detail LIKE '%NET小结%'-- 2分33秒
SELECT ID FROM Asks WHERE CONTAINS (Asks.*,'NET小结')-- 0分40秒

SELECT ID FROM Asks WHERE Subject LIKE '%NET小结%' -- 0分42秒
SELECT ID FROM Asks WHERE CONTAINS (Asks.Subject,'NET小结')-- 0分26秒

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template