alter Verified current stable Not installed? Data Processing

Alter / Delete Partition From Table

Delete Partition From Table

Efficiently delete a specified partition from a table to manage data storage and performance.

$
Terminal
alter table <table_name> drop partition (<partition_spec>);

When To Use

Manage storage effectively by deleting unnecessary table partitions.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
alter table <table_name> drop partition (<partition_spec>);

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
Query OK, 0 rows affected

Time: 0.002s

Power User Variants

Optimized versions

alter table my_table drop partition (p1);

Delete partition p1 from my_table.

alter table sales drop partition (2022_Q1);

Remove the 2022_Q1 partition from the sales table.

Troubleshooting

Common pitfalls

Partition does not exist

Solution: Check the partition specification for accuracy.

Table does not exist

Solution: Ensure the table name is correct.

Command Breakdown

What each part is doing

alter
Base Command
The executable that performs this operation. Here it runs Alter before the shell applies any redirect operators.
<table_name>
table name
The value supplied for table name.
<partition_spec>
partition spec
The value supplied for partition spec.

How To Run

Execution path

  1. Step 1

    Identify the table and partition to delete.

  2. Step 2

    Run the command: alter table {{table_name}} drop partition ({{partition_spec}});

  3. Step 3

    Verify the partition has been removed.

Alternative Approaches

Comparable commands in other tools

Alternative data processing tools for the same job.