/*----------------------------學習篇--全文索引---------------------------*/
use northwind
go/****** object: table [dbo].[employees] script date: 04/29/2015 17:42:43 ******/
set ansi_nulls on
goset quoted_identifier on
gocreate table [dbo].[employees](
[employeeid] [int] identity(1,1) not for replication not null,
[lastname] [nvarchar](20) not null,
[firstname] [nvarchar](10) not null,
[title] [nvarchar](30) null,
[titleofcourtesy] [nvarchar](25) null,
[birthdate] [datetime] null,
[hiredate] [datetime] null,
[address] [nvarchar](60) null,
[city] [nvarchar](15) null,
[region] [nvarchar](15) null,
[postalcode] [nvarchar](10) null,
[country] [nvarchar](15) null,
[homephone] [nvarchar](24) null,
[extension] [nvarchar](4) null,
[photo] [image] null,
[notes] [ntext] null,
[reportsto] [int] null,
[photopath] [nvarchar](255) null,
constraint [pk_employees] primary key clustered
( [employeeid] asc
)with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary]
) on [primary] textimage_on [primary]
goalter table [dbo].[employees] with nocheck add constraint [fk_employees_employees] foreign key([reportsto])
references [dbo].[employees] ([employeeid])
goalter table [dbo].[employees] check constraint [fk_employees_employees]
goalter table [dbo].[employees] with nocheck add constraint [ck_birthdate] check (([birthdate] < getdate()))
goalter table [dbo].[employees] check constraint [ck_birthdate]
go--開啟northwind的全文檢索功能
exec sp_fulltext_database 'enable'
--為northwind建立乙個全文索引'cat_desc'
exec sp_fulltext_catalog 'cat_desc','create'
--在employees表上,在pk_employees索引是提供的引用全文索引的唯一列
exec sp_fulltext_table
'employees', --表名
'create', --動作
'cat_desc', --全文索引名
'pk_employees' --sqlserver的索引名,一般為主鍵索引
--在employee表上建立的全文索引新增到列'notes'
exec sp_fulltext_column
'employees', --表名
'notes', --列名
'add' --動作為新增,即將notes列加入到全文索引中
--執行下列語句後發現沒有返回記錄,原因:記錄匹配的行我們還沒有組裝全文索引
select employeeid,lastname,firstname from employees
where contains(*,'university')
--使用完全組裝:
exec sp_fulltext_table 'employees','start_full'
--完全組裝全文索引後再次執行上述語句,發現有6條記錄
select employeeid,lastname,firstname from employees
where contains(*,'university')
mysql全文索引的坑 MySQL全文索引問題
我有乙個包含以下資料的 文章 mysql select from articles id title body 1 mysql tutorial dbms stands for database 2 how to use mysql well after you went through a 3 o...
建立全文索引
建立全文索引 在進行全文檢索之前,必須先建立和填充資料庫全文索引。為了支援全文索引操作,sql server 7.0新增了一些儲存過程和transact sql語句。使用這些儲存過程建立全文索引的具體步驟如下 括號內為呼叫的儲存過程名稱 1.啟動資料庫的全文處理功能 sp fulltext data...
mysql全文索引
了解 solr 之後 發現全文索引也能做檢索 故了解了下 筆記如下 建立全文索引 alter table table add fulltext index fulltext table 列1 列2 查詢方式 select from table where match 列1 列2 against 查詢...