如果我对表进行分区,我可以在不通知 SQL Server 的情况下替换分区的文件吗?

发布于 2024-08-24 03:46:32 字数 817 浏览 1 评论 0原文

我希望能够将一个表分区交换为另一个表分区,只需在启动服务器之前替换partitionN.ndf即可。

总体目标是能够将一些表行集拆分到不同的文件中,以便在安装应用程序时,它只包含一组。有一些行总是需要的,所以

场景 A

ID     Game         Strategy
1      Squash       Stick to the T
2      Racketball   Drop it at the back
3      Tennis       Serve to the backhand
1000   Croquet      The key is to be really mean
1001   Billiards    Glare a lot

场景 B

ID     Game         Strategy
1      Squash       Stick to the T
2      Racketball   Drop it at the back
3      Tennis       Serve to the backhand
1000   Baseball     Favour third
1002   Pool         Snooker them, be irritating

这里我将从 1000 个 ID 中划分出来,并将较低的数字保留在公共数据库中。在特定于场景的分区中,将有大量 ID 需要与公共数据库中的表保持引用完整性。

那行得通吗?或者我是否需要在服务器运行时向服务器发出一些分区命令来替换它?我想问题的一部分是:服务器是否只是启动并读取文件,或者它是否维护缓存和其他对替换敏感的东西?

I would like to be able to swap one table partition for another, just by replacing partitionN.ndf before starting up the server.

The general aim is to be able to split out some sets of table rows into different files so that when the app is installed, it only goes with one set. There are some rows that are always needed, so

Scenario A

ID     Game         Strategy
1      Squash       Stick to the T
2      Racketball   Drop it at the back
3      Tennis       Serve to the backhand
1000   Croquet      The key is to be really mean
1001   Billiards    Glare a lot

Scenario B

ID     Game         Strategy
1      Squash       Stick to the T
2      Racketball   Drop it at the back
3      Tennis       Serve to the backhand
1000   Baseball     Favour third
1002   Pool         Snooker them, be irritating

Here I would partition out the IDs from 1000, and keep the low numbers in the common database. There will be lots of IDs needing to maintain referential integrity with tables in the common database in the scenario-specific partitions.

Would that work? Or would I need to issue some partitioning command to the server to replace it while the server is running? I suppose part of the question is: does the server just start up and read the files, or does it maintain caches and other things that would be sensitive to the replacement?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

一人独醉 2024-08-31 03:46:32

我认为它根本不会起作用。文件的结构比单个表(gam、sgam、pfs、文件头页)复杂得多,并且分区表的每个分区都有一个 HoBT ID,并且您的新文件将不会具有相同的 HoBT ID 您的示例不是分区

编辑:

旨在解决的问题,您基本上是在尝试使用固定的行的特定部分以及基于可变行的数量预先填充一个表安装标准。

就我个人而言,我建议您立即忽略分区表,它不是适合这项工作的工具 - 您可以选择将值拆分为 2 个物理表,然后在两个物理表上放置一个视图,将两个表联合起来一起。

这至少意味着您只是尝试替换表,而不是单个分区 - 但我仍然不喜欢这种方法 - 如果我有足够的权限来安装后添加和删除文件组/文件,那么我将有足够的权限使用正确的数据加载例程并根据需要加载数据。

如果您需要对值的固定部分和可变部分进行物理分离,那么您可以在需要时使用视图方法。

I do not think that it will work at all. The File is a far more complex structure than the single table (gam, sgam, pfs, file header pages) as well as the partitioned table has a HoBT ID per partition within the table and your new file will not have the same HoBT ID for the IAM etc.

Edit :

Your example is not the problem that partitioning is designed to solve, you are basically trying to have a table pre-populated with a certain portion of rows that are fixed, and a number of rows that are variable based on an installation criteria.

Personally I suggest you ignore partitioned tables immediately for this, it is not the right tool for the job - you could choose instead to split the values into 2 physical tables and then place a view on top of the two, union'ing the two tables together.

This at least means you are only trying to replace the table, not an individual partition - but I still wouldn't like that approach - if I have enough privledges to post install add and remove filegroups / files, then I would have enough privledges to use a proper data loading routine and just load the data as required.

If you needed physical seperation of the fixed and variable portion of the values, then you can use the view approach afterwards, if required.

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