問題描述
我有一個主鍵是 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 索引的表上的主鍵的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!