From 4fd1ee8d9cdd48035843453060e8763150d1ca4e Mon Sep 17 00:00:00 2001 From: xking Date: Thu, 18 Dec 2025 09:50:26 +0800 Subject: [PATCH] update hive --- hive/hive表删除数据的几种方式.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hive/hive表删除数据的几种方式.md b/hive/hive表删除数据的几种方式.md index ad20c99..d9425b9 100644 --- a/hive/hive表删除数据的几种方式.md +++ b/hive/hive表删除数据的几种方式.md @@ -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; + ``` \ No newline at end of file