非分区表上的分区索引

时间:2011-02-18 20:06:44

标签: sql sql-server partitioning clustered-index database-partitioning

如果有可用的分区功能和方案,如何在未分区的表上创建分区索引。这是我在某处读到的练习,而不是真正的问题

create partition function func(datetime)
as range right for values
('20040601', '20050601')
go
create partition scheme scheme1
as partition func
to ('primary')
go

create table student
(
studentid int not null primary key nonclustered,
firstname varchar(30) not null,
date datetime not null
)

我在考虑

create clustered index IX_StudentID_Date
on student(studentid, date)

但是表没有分区,所以如何创建索引,而不对表进行分区?

1 个答案:

答案 0 :(得分:1)

对“表”进行分区时,实际上是对聚簇索引进行分区。因此,对非聚集索引进行分区实际上与分区“表”

相同
    CREATE NONCLUSTERED INDEX IX_StudentID_Date 
        ON student(studentid, date) 
        ON scheme1(date)   

您只需要确保分区字段是索引的一部分。

相关问题