T-SQL:选择稀疏表?

发布于 2024-09-16 18:44:38 字数 298 浏览 4 评论 0原文

我正在将大量大部分为空的表迁移到 SQL Server 2008。

这些表是一个大逻辑表的垂直分区。

问题是这个逻辑表有超过 1024 列。

鉴于大多数字段为空,我计划使用稀疏表。

到目前为止,对于我的所有表,我一直在使用 SELECT...INTO,它运行得非常好。

但是,现在我遇到“CREATE TABLE 失败,因为表 'MyBigTable' 中的列 'xyz' 超出了 1024 列的最大值。”

有什么方法可以执行 SELECT...INTO 以便它创建具有稀疏支持的新表?

I am migrating a large quantity of mostly empty tables into SQL Server 2008.

The tables are vertical partitions of one big logical table.

Problem is this logical table has more than 1024 columns.

Given that most of the fields are null, I plan to use a sparse table.

For all of my tables so far I have been using SELECT...INTO, which has been working really well.

However, now I have "CREATE TABLE failed because column 'xyz' in table 'MyBigTable' exceeds the maximum of 1024 columns."

Is there any way I can do SELECT...INTO so that it creates the new table with sparse support?

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

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

发布评论

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

评论(2

折戟 2024-09-23 18:44:38

您可能想要做的是手动创建表并使用 INSERT ... SELECT 语句填充它。

要创建表,我建议编写不同组件表的脚本并合并它们的定义,根据需要使它们全部SPARSE。然后只需运行单个 CREATE TABLE 语句即可。

What you probably want to do is create the table manually and populate it with an INSERT ... SELECT statement.

To create the table, I would recommend scripting the different component tables and merging their definitions, making them all SPARSE as necessary. Then just run your single CREATE TABLE statement.

若有似无的小暗淡 2024-09-23 18:44:38

你不能(并且可能无论如何也不想)。有关MSDN 文档。

问题在于稀疏表是一种物理存储特征,而不是逻辑特征,因此 DBMS 引擎无法知道要复制该特征。此外,它是一个表范围的属性,并且 SELECT 可以有多个基础源表。请参阅我链接的页面的“备注”部分,其中讨论了如何仅使用默认组织详细信息。

You cannot (and probably don't want to anyway). See INTO Clause (TSQL) for the MSDN documentation.

The problem is that sparse tables are a physical storage characteristic and not a logical characteristic, so there is no way the DBMS engine would know to copy over that characteristic. Moreover, it is a table-wide property and the SELECT can have multiple underlying source tables. See the Remarks section of the page I linked where it discusses how you can only use default organization details.

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