gpt4 book ai didi

sql-server - 如何查找 Azure Synapse 专用 SQL 池中分区的范围值

转载 作者:行者123 更新时间:2023-12-03 07:09:42 25 4
gpt4 key购买 nike

我在 Azure Synapse 专用 SQL 池中有一个 dbo.Test_Partitioned 表,该表在 TEST_SEQ 列上进行范围右侧分区。

我正在尝试自动化 future 数据的分区创建过程。如果最后一个分区超过 2 亿条记录,我们就将其拆分。为此,我计划使用 CTAS 创建一个新表来保存数据(以清空分区),然后拆分,最后将数据切换回。

我能够找到最后一个分区号,但是有没有办法找到使用查询创建最后一个分区的范围值。我需要在之前的范围分割值中添加一个间隔值来进行分割。

提前致谢。

最佳答案

经过进一步研究,我得到了结果。

SELECT 
t.name AS TableName,
i.name AS IndexName,
p.partition_number,
p.partition_id,
f.type_desc,
c.name AS PartitioningColumnName,
CONVERT(nvarchar(255), r.value) as boundary
FROM sys.tables AS t
JOIN sys.indexes AS i
ON t.object_id = i.object_id
JOIN sys.partitions AS p
ON i.object_id = p.object_id AND i.index_id = p.index_id
JOIN sys.partition_schemes AS s
ON i.data_space_id = s.data_space_id
JOIN sys.partition_functions AS f
ON s.function_id = f.function_id
LEFT JOIN sys.partition_range_values AS r
ON f.function_id = r.function_id and r.boundary_id = p.partition_number
JOIN sys.index_columns AS ic
ON ic.object_id = i.object_id
AND ic.index_id = i.index_id AND ic.partition_ordinal > 0
JOIN sys.columns AS c
ON t.object_id = c.object_id
WHERE t.name = @table
AND c.column_id = ic.column_id
ORDER BY p.partition_number;

关于sql-server - 如何查找 Azure Synapse 专用 SQL 池中分区的范围值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70666493/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com