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即可
我都试过了 1#设置主键时,指定了nonclustered,所以就不存在设置主键时默认引索问题,方法可行。 2#方法针对1# nonclustered建表方式是行的通的。 但是我遇到的问题是,建表的时候没有指定nonclustered,例如: create table dds (c1 int primary key not null, c2 int not null ) 结果就是主键名和聚簇引索名相同(问题关键所在),然后我再: drop index 聚簇引索名 on dds 提示消息: 不允许对索引 '***' 显式地使用 DROP INDEX。该索引正用于 PRIMARY KEY 约束的强制执行。 这该怎么解决???
(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
*/
1#设置主键时,指定了nonclustered,所以就不存在设置主键时默认引索问题,方法可行。
2#方法针对1# nonclustered建表方式是行的通的。
但是我遇到的问题是,建表的时候没有指定nonclustered,例如:
create table dds
(c1 int primary key not null,
c2 int not null
)
结果就是主键名和聚簇引索名相同(问题关键所在),然后我再:
drop index 聚簇引索名 on dds
提示消息:
不允许对索引 '***' 显式地使用 DROP INDEX。该索引正用于 PRIMARY KEY 约束的强制执行。
这该怎么解决???