非分区表上的分区索引

发布于 2024-10-18 06:09:28 字数 518 浏览 5 评论 0原文

尽管有可用的分区函数和方案,但如何在未分区的表上创建分区索引。这是我在某处读到的练习,不是

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

删除→记忆 2024-10-25 06:09:28

当您对“表”进行分区时,您实际上是在对聚集索引进行分区。因此,对非聚集索引进行分区实际上与对“表”进行分区相同,

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

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

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"

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

you just have to make sure that the partition field is part of the index.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文