无法删除具有 FULLTEXT 索引的表上的主键

Can#39;t delete primary key on table with FULLTEXT index(无法删除具有 FULLTEXT 索引的表上的主键)

本文介绍了无法删除具有 FULLTEXT 索引的表上的主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主键是 int 数据类型的表.我想删除这个列(因为它没有使用,我担心这个列可能会达到int数据类型的最大限制,所以我们不妨删除它.)

I have a table with a primary key that is an int data type. I want to drop this column (as it is unused, and I fear this column may reach the maximum limit of the int data type, so we may as well drop it.).

首先,我无法删除我试图首先删除约束:

First, I could not drop I tried to first drop the constraint with:

ALTER TABLE dbo.MyTable DROP CONSTRAINT PK_MyTableID

我收到错误:

无法删除索引PK_MyTableID",因为它强制使用表或索引视图MyTable"的全文键.

Cannot drop index 'PK_MyTableID' because it enforces the full-text key for table or indexed view 'MyTable'.

我不明白这个错误,因为主键是一个int,我不认为这个表有一个FULLTEXT索引,但如果有,我不需要它.

I don't understand this error, because the primary key is an int, and I don't think this table has a FULLTEXT index, but if it does, I don't need it.

我可以在删除 FULLTEXT 索引后删除该列:

I was able to drop the column after deleting the FULLTEXT index:

DROP FULLTEXT INDEX ON dbo.MyTable

推荐答案

我相信表格上有全文索引.全文索引要求您具有唯一键:

I believe there is a full text index on the table. A full text index requires you to have unique key:

来自 MSDN:KEY INDEX index_name是 table_name 上唯一键索引的名称.KEY INDEX 必须是唯一的、单键的、不可为空的列.为全文唯一键选择最小的唯一键索引.为了获得最佳性能,我们建议全文键使用整数数据类型.

From MSDN: KEY INDEX 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.

您可以使用以下方法检查表格全文索引:

You can check for a tables full text indexes using:

SELECT object_id, property_list_id, stoplist_id FROM sys.fulltext_indexes
    where object_id = object_id('myTable'); 

这篇关于无法删除具有 FULLTEXT 索引的表上的主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:无法删除具有 FULLTEXT 索引的表上的主键

基础教程推荐