当前位置:   article > 正文

SQL(HIVE)-insert用法_hive sql insert

hive sql insert

hive创建表

  • insert法
# select插入法(into 追加,overwrite重写)
insert into table tablename1 select * from tablename2
# 自定义插入法
insert into table tablename1 values ('Rsd','11');
# 对多个表进行插入操作
from tablename3
insert overwrite table tablename1 [partition (partcol1=val1,partclo2=val2)] select_statement1
insert overwrite table tablename2 [partition (partcol1=val1,partclo2=val2)] select_statement2
eg:
from tablename3
insert overwrite table tablename1
select tablename3.key
insert overwrite table tablename2
select tablename3.value;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • create法
# like 复制表结构
create table tablename1 like tablename2;
# as  结构和值都会复制
create table tablename1 as select * from tablename2;
# 直接创建
CREATE TABLE `database.tablename1 `( 
`dept_no` int, 
`addr` string, 
`tel` string)
partitioned by(statis_date string ) 
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/397281
推荐阅读
相关标签
  

闽ICP备14008679号