T-SQL:选择稀疏表?
我正在将大量大部分为空的表迁移到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能想要做的是手动创建表并使用
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 singleCREATE TABLE
statement.你不能(并且可能无论如何也不想)。有关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.