SQL 2000 建全文索引

 -全文索引的一个例子,在查询分析器中使用:
use CDC
go
--打开数据库全文索引的支持
execute sp_fulltext_database 'enable'
go
--建立全文目录Cat_Demo
execute sp_fulltext_catalog 'Cat_Demo', 'create'
go
--为titles表建立全文索引数据元,UPKCL_titleidind是主键所建立的唯一索引,可由sp_help titles得知
execute sp_fulltext_table 'FreeText','create', 'Cat_Demo', 'PK_FreeText'
go

--设置全文索引列名
exec sp_fulltext_column 'FreeText', 'Subject', 'add'
go
exec sp_fulltext_column 'FreeText', 'Contents', 'add'
go

--建立全文索引
exec sp_fulltext_table 'FreeText', 'activate'
go

--填充全文索引目录
exec sp_fulltext_catalog 'Cat_Demo', 'start_full'
go

--使用contains和freetext
select Subject, Contents from [FreeText]
where contains(Subject, '"star"')
go
select Subject, Contents from [FreeText]
where freetext(Subject,Contents 'bb')
go
select Subject, Contents from [FreeText]
where freetext(*, '"star"')
go
select Subject, Contents from [FreeText]
where contains(*, 'aa ')
go
select title, notes from titles
where freetext (*, 'computer')
go


SELECT top 20 *
FROM [FreeText]

你可能感兴趣的:(sql,数据库,table,database)