Is it possible to add partitions in synapse using Partition Function

Narayana Nayudu 60 Reputation points
2023-02-20T03:04:31.8+00:00

We know all of us can add partitions on a table in synapse dedicated pool using CTAS. But is there any other way to add partitions on a table in synapse dedicated pool ?

Azure SQL Database
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,241 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,492 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 34,351 Reputation points Microsoft Employee
    2023-02-21T10:12:13.7533333+00:00

    Hi Narayana Nayudu ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your question here.

    As I understand your query, you want to know if there is any way to add partition on the table in dedicated sql pool in synapse other than CTAS.

    You can use the ALTER TABLE command with the TRUNCATE_TARGET option. This option allows you to overwrite existing data in the partition with new data. It not an alternate to CTAS , however, you can create partition on existing data by altering the table .

    To switch partitions between two tables, you must ensure that the partitions align on their respective boundaries and that the table definitions match.

    Loading data into partitions with partition switching is a convenient way to stage new data in a table that is not visible to users. It can be challenging on busy systems to deal with the locking contention associated with partition switching.

    To clear out the existing data in a partition, an ALTER TABLE used to be required to switch out the data. Then another ALTER TABLE was required to switch in the new data.

    In dedicated SQL pool, the TRUNCATE_TARGET option is supported in the ALTER TABLE command. With TRUNCATE_TARGET the ALTER TABLE command overwrites existing data in the partition with new data. Below is an example :

    ALTER TABLE dbo.FactInternetSales_NewSales SWITCH PARTITION 2 TO dbo.FactInternetSales PARTITION 2 WITH (TRUNCATE_TARGET = ON);  
    

    Reference documentation: Load new data into partitions that contain data in one step


    Hope it helps. Just checking in to see if the below answer helped. Please do consider clicking Accept Answer as accepted answers help community as well. Also, please click on Yes for the survey 'Was the answer helpful' 

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.