日期:2014-05-17  浏览次数:20376 次

求教!SQL聚簇引索的删除与建立
SQL2008创建表,设置主键时系统默认在主键上创建聚簇引索。怎样,在不变更主键的情况下,删除这个默认的聚簇引索?我的目的是想在其它列上重新建立一个聚簇引索,小弟菜鸟,谢谢解答!

------解决方案--------------------
for example,

create table dds
(c1 int not null,
 c2 int not null
 constraint pk_dds primary key nonclustered (c1)
)

create clustered index ix_dds_c2 on dds(c2)


sp_helpindex dds

/*
index_name          index_description                                        index_keys
------------------  ------------------------------------------------------  --------------
ix_dds_c2           clustered located on PRIMARY                                c2
pk_dds              nonclustered, unique, primary key located on PRIMARY        c1
*/

------解决方案--------------------
直接drop掉聚集索引然后在需要的列上create clustered index即可
------解决方案--------------------
其实很简单,先把pk删了,这样聚集索引也没了,然后先创建聚集索引,然后创建PK。