Clear the specified content of the table
Both partitioned and non-partitioned tables are applicable
1. truncate (only delete the data in the table, retain the table structure)
truncate table table_name;
#truncate操作用于删除指定表中的所有行
Second, the partition table
1. Delete the specific partition
alter table table_name drop partition(partition_name='')
2. Delete some data of a specific partition
INSERT OVERWRITE TABLE table_name PARITION( etl_cycle_id='20230106') SELECT * FROM table_name WHERE etl_cycle_id<'20230106';
#WHERE后的条件是需要保留的数据的查询结果,即删除20230106之后的数据
Three, non-partitioned table
INSERT OVERWRITE TABLE table_name SELECT * FROM table_name WHERE etl_cycle_id<'20230106';
#WHERE后的条件是需要保留的数据的查询结果,即删除20230106之后的数据