我的桌子上有两个索引:
CREATE CLUSTERED INDEX [IXAddrbookCrtDtm] ON [dbo].[Addrbook]
(
[AbkOrgGrpID] ASC,
[AddrbookID] ASC
)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF,
ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
GO
和
ALTER TABLE [dbo].[Addrbook]
ADD CONSTRAINT [PKAddrbook_New]
PRIMARY KEY NONCLUSTERED
(
[AbkOrgGrpID] ASC,
[AddrbookID] ASC
)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF,
ONLINE = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON)
GO
我需要只有一个Clustered Primary Key Index而不是两个以上。删除和重新创建表不是一种选择。
是否有像
这样的东西CREATE CLUSTERED INDEX IXAddrbookCrtDtm ON
Addrbook(AbkOrgGrpID,AddrbookID)
PRIMARY KEY WITH (DROP_EXISTING = ON);
这样我就可以删除非聚集索引了吗?
答案 0 :(得分:0)
删除索引并创建新索引,而不是删除表格。
涉及的步骤..
删除索引
在[dbo]上删除索引IXAddrbookCrtDtm。[Addrbook]
删除约束
alter table [dbo]。[Addrbook] 删除约束PKAddrbook_New
创建新的主键
alter table [dbo]。[Addrbook]添加主键(AbkOrgGrpID,AddrbookID)