This commit is contained in:
2023-09-07 17:25:32 +08:00
parent 074b2d3453
commit fc4d35fd3f
5 changed files with 424 additions and 3 deletions

View File

@ -0,0 +1,54 @@
## hive 删除数据
### 删除表
```sql
-- hive删除表
drop table table_name;
-- 永久性删除,不能恢复:
drop table table_name purge;
```
### 清空数据
```sql
-- hive删除表中数据
truncate table table_name;
-- hive按分区删除数据
alter table table_name drop partition (partition_name='分区名')
```
### 重写数据
与删除条件相反,如删除 date=0528 的数据
那么 重写数 的条件为 date!=0528
**分区表**
```
删除具体partition的部分数据
INSERT OVERWRITE TABLE table_name PARTITION(year='2021')
SELECT * FROM table_name WHERE year='2021' and xx;
```
**非分区表**
```
INSERT OVERWRITE TABLE table_name SELECT * FROM table_name WHERE xx;
```