Get the App
SLTechnology News&Howtos  ›  Database  › 

How to implement Partition addition and deletion algorithm in SQLServer

Shulou Source: shulou.com Published: 2022-05-31 19:23:23 09月13日 Update

This article shows you how to achieve partition addition and deletion algorithms in SQLServer, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The first is the method of adding a data table to the partitioned table: [dbo]. [SP_Helper_Partition_Add] @ SrcTable nvarchar (256), the table to be added @ DestTable nvarchar (256), the target table @ idxOnDest nvarchar (1024), the index creation statement on the target table @ Partition_func_name nvarchar (256), the partition function @ PartCol nvarchar (256), the column of the partition @ SonIsPart tinyint=1 The partitioning algorithm for the table to be added is as follows: get the value of the partitioned column of the source table Add a restriction on the uniqueness of the partition column values on the source table; then determine whether there is a partition that can just hold the table; if it does not exist, return; create the same index on the source table as the target table; now that the structure of the source table and the target table are the same, the contents of the source table can be stored on the target partition, use alter table switch to complete the partition Algorithm for deleting a partition [dbo]. [SP_Helper_Partition_Delete] @ SrcTable nvarchar (1024), delete partition @ IdxOnTable nvarchar (1024) from the table, index creation statement @ Part_func nvarchar (1024), partition function name @ PartCol nvarchar (256), partition column @ PartIndex int Whether the index @ IdxIsPart tinyint of the partition to be deleted is partitioned on another partition function the algorithm is as follows: first, copy the table structure of a temporary table according to the table structure of the source table. Get the boundary value of the partition to be deleted; create restrictions on temporary tables; create indexes on this table; swap specified partitions to temporary tables using alter switch; delete temporary tables

The above is how to implement partition add and delete algorithms in SQLServer. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Indexes algorithms goals content functions structures skills knowledge statements restrictions conciseness consistency brevity uniqueness that is data datasheets articles methods and more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS vpn Apple Shulou Tech Info MariaDB