問(wèn)題描述
我有一個(gè)主鍵是 int
數(shù)據(jù)類型的表.我想刪除這個(gè)列(因?yàn)樗鼪](méi)有使用,我擔(dān)心這個(gè)列可能會(huì)達(dá)到int
數(shù)據(jù)類型的最大限制,所以我們不妨刪除它.)
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.).
首先,我無(wú)法刪除我試圖首先刪除約束:
First, I could not drop I tried to first drop the constraint with:
ALTER TABLE dbo.MyTable DROP CONSTRAINT PK_MyTableID
我收到錯(cuò)誤:
無(wú)法刪除索引PK_MyTableID",因?yàn)樗鼜?qiáng)制使用表或索引視圖MyTable"的全文鍵.
Cannot drop index 'PK_MyTableID' because it enforces the full-text key for table or indexed view 'MyTable'.
我不明白這個(gè)錯(cuò)誤,因?yàn)橹麈I是一個(gè)int
,我不認(rèn)為這個(gè)表有一個(gè)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:
來(lái)自 MSDN:KEY INDEX index_name是 table_name 上唯一鍵索引的名稱.KEY INDEX 必須是唯一的、單鍵的、不可為空的列.為全文唯一鍵選擇最小的唯一鍵索引.為了獲得最佳性能,我們建議全文鍵使用整數(shù)數(shù)據(jù)類型.
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');
這篇關(guān)于無(wú)法刪除具有 FULLTEXT 索引的表上的主鍵的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!