update hive

This commit is contained in:
2025-12-18 09:50:26 +08:00
parent 6a9188990a
commit 4fd1ee8d9c

View File

@@ -51,4 +51,24 @@ alter table table_name drop partition (partition_name='分区名')
INSERT OVERWRITE TABLE table_name SELECT * FROM table_name WHERE xx;
```
**临时表**
```
-- 1. 创建临时表存储处理后的数据临时表可使用CREATE TEMPORARY TABLE会话结束自动删除
CREATE TEMPORARY TABLE tmp_my_table
AS
SELECT col1, col2, col3
FROM my_table
WHERE col3 > 100; -- 对原表数据进行过滤/转换
-- 2. 覆盖原表(清空原表并写入临时表的数据)
INSERT OVERWRITE TABLE my_table
SELECT * FROM tmp_my_table;
-- 3. 手动删除临时表若使用的是普通表而非TEMPORARY表
DROP TABLE IF EXISTS tmp_my_table;
```