3

我试图在我的表格列中创建全文索引,但它给了我错误。

我的查询如下:

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

它给出了这个错误:

消息 7653,级别 16,状态 2,第 1 行“pname”不是强制执行全文搜索键的有效索引。全文搜索键必须是唯一的、不可为空的、单列索引,该索引不脱机,未在非确定性或不精确的非持久计算列上定义,没有过滤器,最大大小为 900字节。为全文键选择另一个索引。

4

1 回答 1

5

您应该为您的 PRIMARY KEY 命名,并将其用作最后一条语句中的 KEY INDEX。

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

关键索引 index_name

Is the name of the unique key index on table_name. The KEY INDEX must be a unique, single-key, non-nullable column. Select the smallest unique key index for the full-text unique key. For the best performance, we recommend an integer data type for the full-text key.

于 2013-02-05T12:46:09.840 回答