hive建表、导入数据、匹配

1.建表(建立非重复表,分隔符设置为“,”)
CREATE TABLE IF NOT EXISTS imei_guid(imei string)
ROW FORMAT DELIMITED FIELDS
TERMINATED BY ‘,’;

2.导入(将本地文件夹的数据上传到hive,适用数据量较大情况)
=CONCATENATE("(’",C2,"’),")
load data inpath “hdfs://alg-hdfs/business/datacenter-platform/compass/adhoc/xxx.txt”
into table imei_guid;

3.导入(直接insert into明细,适用数据量较小情况)
insert overwrite table os_pso.imei_guid
values
(‘862267048’),
(‘862287041’);

4.匹配(建新表)
create table if not exists os_pso.imei_guid4 as
select a.imei1,b.guid
from os_pso.imei_guid a
left join
(select imei,guid,imei_md5,guid_md5 from os_allawn_tech_dw.dws_imei_guid_mapping_all_d) b on a.imei1 = b.imei

5.匹配(不建新表)
select a.imei1,b.guid
from os_pso.imei_guid a
left join
(select imei,guid
from os_allawn_tech_dw.dws_imei_guid_mapping_all_d
where bak_dayno=20200824
group by imei,guid) b on a.imei1 = b.imei;

6.改表名
ALTER TABLE os_pso.imei_guid RENAME TO new_table_name;

7.改列名
ALTER TABLE os_pso.imei_guid CHANGE imei imei1 STRING

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值