Hive数据入库

查看hadoop fs文件大小

    hadoop fs -du -h /data/source/

查看hadoop fs文件目录

    hadoop fs -ls /data/source/

查看hadoop fs文件夹内所有内容

    hadoop fs -cat /data/source/*

将文件放入hdfs

hdfs dfs -copyFromLocal 本机文件目录 放入的hdfs目录

    hdfs dfs -copyFromLocal /data/nm_use_1.txt /data/

hive中建立数据表


    create table nm_use
    (month string comment '账期' ,
    province string comment '省份' ,
    business_type string comment '业务类型' ,
    product_type string comment '产品类型' ,
    product_name string comment '产品名称' ,
    business_hall string comment '本月是否使用手厅' ,
    arpu_range string comment 'ARPU分档' ,
    dou_range string comment 'DOU分档' ,
    mou_range string comment 'MOU分档' ,
    over_flow_range string comment '超套流量分档' ,
    over_phone_range string comment '超套语音分档' ,
    over_flow_income_range string comment '超套流量收入分档' ,
    over_phone_income_range string comment '超套语音收入分档' ,
    user_number string comment '用户数' ,
    income string comment '收入' ,
    flow string comment '流量使用量' ,
    phone string comment '语音使用量' ,
    over_flow string comment '超套流量使用量' ,
    over_phone string comment '超套语音使用量' ,
    over_flow_income string comment '超套流量收入' ,
    over_phone_income string comment '超套语音收入' )
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    STORED AS TEXTFILE;

修改成utf8字符集,来支持中文字符

    alter table nm_use character set utf8

hive中加载hdfs中数据

inpath后填写hdfs中目标文件路径

    load data inpath '/data/nm_use_1.txt' into table nm_use;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值