第18天: hive数据加载 从文件加载到hive表讲解和案例操作、从查询插入数据到hive表讲解和案例操作

Hive学习实战   
--------------------------------------------------------------
Hive从入门到实战【40讲】---笔记记录
--------------------------------------------------------------
 
hive命令
1、show tables;
2、show databases;
3、 desc login; ---查看表结构。
4、 show partitions test5; --查看分区


第18天:  hive数据加载  从文件加载到hive表讲解和案例操作、从查询插入数据到hive表讲解和案例操作


insert overwrite table tablname1 [partition ]
if not existes   select_statement1 from statement;


从别的表查询,插入到其他表中。


从查询插入数据到hive表
示例:
insert overwrite table login_user  select destinct uid from
login_log  
从登录日志表查询登录用户
插入到表login_user中,如果login_user以有数据,则覆盖,
否则创建


insert overwrite table  login user partiton(dt=..)
selct  ...




create table login_user(
  uid string 
  
)
partitioned by (dt string)
 
stored as textfile; 




insert overwrite table  login_user
partition(dt='20150207') 
select distinct uid from login where dt='20150207'








create table userinfo(
  id int,
  name string
)
 
row format delimited
fields terminated by ','
stored as textfile; 
 
create table mutil1(
  id int,
  name string
 )
row format delimited
fields terminated by ','
stored as textfile; 


create table  mutil2(
  sumid int,
  name string

row format delimited
fields terminated by ','
stored as textfile; 


load data local inpath '/hadoop/hive0.9/testHive/userinfo.txt'
into table userinfo;


-------
同事插入两张表中。
------
from  userinfo
insert overwrite table mutil1  select id ,name
insert overwrite table mutil2 
select count(distinct id),name group by name;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值