想用T2表中的MchtName更新到T1表中,两表用Id关联
Hive中不能用update,只能用 insert overwrite,但insert overwrite不支持指定字段,要全表更新,
T1表有100个甚至更多字段,难道都要全量重写?
这个语句要怎么写?
insert overwrite 怎么更新表中指定列值
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
11条回答 默认 最新
Watch the clown 2023-07-23 21:31关注获得1.05元问题酬金 我记得是不是你好像发过这个问题的,创个新表就ok
CREATE TABLE updated_t1 ( Id int, MchtName string, field1 string, field2 string, ... field100 string ); INSERT OVERWRITE TABLE updated_t1 SELECT T1.Id, T2.MchtName, T1.field1, T1.field2, ..., T1.field100 FROM T1 JOIN T2 ON T1.Id = T2.Id; DROP TABLE T1; ALTER TABLE updated_t1 RENAME TO T1;评论 打赏 举报解决 1无用