2013-02-05 99 views
3

我想craete全文索引在我的表列但它給我錯誤。全文索引不創建

我的查詢如下:

create table products 
(
p_id int primary key, 
p_name varchar(50), 
) 

insert into products values(1,'Sugar') 
insert into products values(2,'Tea') 
insert into products values(3,'Flour') 
insert into products values(5,'Soap') 

create index pname on products(p_name) 
select * from products 

create fulltext catalog product as default 

create fulltext index on products(p_name) key index pname on product 

它給這個錯誤:

Msg 7653, Level 16, State 2, Line 1 'pname' is not a valid index to enforce a full-text search key. A full-text search key must be a unique, non-nullable, single-column index which is not offline, is not defined on a non-deterministic or imprecise nonpersisted computed column, does not have a filter, and has maximum size of 900 bytes. Choose another index for the full-text key.

回答

2

你應該給一個名稱,你的主鍵,把它作爲最後一條語句的重要指標。

create table products 
(
p_id int CONSTRAINT [PK_products] PRIMARY KEY, 
p_name varchar(50), 
) 

.... 
create fulltext index on products(p_name) key index PK_products on product 

KEY INDEX index_name

是對table_name的唯一鍵索引的名稱。 KEY INDEX必須是唯一的,單鍵不可空列。爲全文唯一鍵選擇最小的唯一鍵索引。爲了獲得最佳性能,我們建議爲全文密鑰提供整數數據類型。

+0

好的謝謝你解決我的問題。 – Mufasil