hive导出数据

导出的方式
1.hadoop命令的方式,get、text

hive> select * from student2;
OK
xiaoming    10
xiaohong    12
xiaoli  13
xiaowang    11
lucy    21
lily    22
Time taken: 1.064 seconds, Fetched: 6 row(s)
hive> desc formatted student2;
OK
# col_name              data_type               comment             

name                    string                                      
age                     int                                         

# Detailed Table Information         
Database:               default                  
Owner:                  root                     
CreateTime:             Thu Aug 18 19:51:17 CST 2016     
LastAccessTime:         UNKNOWN                  
Protect Mode:           None                     
Retention:              0                        
Location:               hdfs://ubuntu:9000/user/hive/warehouse/data  
Table Type:             MANAGED_TABLE            
Table Parameters:        
    COLUMN_STATS_ACCURATE   false               
    numFiles                0                   
    numRows                 -1                  
    rawDataSize             -1                  
    totalSize               0                   
    transient_lastDdlTime   1471521331          

# Storage Information        
SerDe Library:          org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe      
InputFormat:            org.apache.hadoop.mapred.TextInputFormat     
OutputFormat:           org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat   
Compressed:             No                       
Num Buckets:            -1                       
Bucket Columns:         []                       
Sort Columns:           []                       
Storage Desc Params:         
    field.delim             \t                  
    line.delim              \n                  
    serialization.format    \t                  
Time taken: 4.132 seconds, Fetched: 34 row(s)

root@ubuntu:~# ls
a.c  bea  Oracle  svn  test.txt
root@ubuntu:~# hadoop fs -get hdfs://ubuntu:9000/user/hive/warehouse/data/student2.txt student.txt
root@ubuntu:~# ls
a.c  bea  Oracle  student.txt  svn  test.txt
root@ubuntu:~# cat student.txt 
lucy    21
lily    22

root@ubuntu:~# hadoop fs -texthdfs://ubuntu:9000/user/hive/warehouse/data/student2.txt  > student.txt

2.通过insert……directory 方式

inset overwrite [local] directory '/root/data' [row format delinited fields terminated by '\t'] select name,age from student;

local情况下才能使用row format
3.shell命令加管道:
hive -f/e |sed/grep/awk >file

root@ubuntu:/app/bigdata/hive-0.13.0/bin# ./hive -e "select * from student2"
16/08/19 18:44:39 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect.  Use hive.hmshandler.retry.* instead

Logging initialized using configuration in jar:file:/app/bigdata/hive-0.13.0/lib/hive-common-0.13.0.jar!/hive-log4j.properties
OK
xiaoming    10
xiaohong    12
xiaoli  13
xiaowang    11
lucy    21
lily    22
Time taken: 1.143 seconds, Fetched: 6 row(s)
root@ubuntu:/app/bigdata/hive-0.13.0/bin# ./hive -S -e "select * from student2" 
16/08/19 18:44:57 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect.  Use hive.hmshandler.retry.* instead
xiaoming    10
xiaohong    12
xiaoli  13
xiaowang    11
lucy    21
lily    22

4.第三方工具,sqoop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值