非分区表上的分区索引
尽管有可用的分区函数和方案,但如何在未分区的表上创建分区索引。这是我在某处读到的练习,不是
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)
真正问题,但表没有分区,那么如何在不分区表的情况下创建索引?
How to create a partitioned index on a table which is not partitioned although there is a partition function and scheme available. It is an exercise I read somewhere, not a real problem
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
)
i was thinking of
create clustered index IX_StudentID_Date
on student(studentid, date)
but the table is not partitioned, so how to create the index, without partitioning the table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您对“表”进行分区时,您实际上是在对聚集索引进行分区。因此,对非聚集索引进行分区实际上与对“表”进行分区相同,
您只需确保分区字段是索引的一部分即可。
When you partition the "table" you are actually partitioning the clustered index. So partitioning a non clustered index is actually the same as partitioning a "table"
you just have to make sure that the partition field is part of the index.