hive导出数据

来源:互联网 发布:中国m2历年数据增速 编辑:程序博客网 时间:2024/05/17 13:42

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

hive> select * from student2;OKxiaoming    10xiaohong    12xiaoli  13xiaowang    11lucy    21lily    22Time 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:~# lsa.c  bea  Oracle  svn  test.txtroot@ubuntu:~# hadoop fs -get hdfs://ubuntu:9000/user/hive/warehouse/data/student2.txt student.txtroot@ubuntu:~# lsa.c  bea  Oracle  student.txt  svn  test.txtroot@ubuntu:~# cat student.txt lucy    21lily    22root@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.* insteadLogging initialized using configuration in jar:file:/app/bigdata/hive-0.13.0/lib/hive-common-0.13.0.jar!/hive-log4j.propertiesOKxiaoming    10xiaohong    12xiaoli  13xiaowang    11lucy    21lily    22Time 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.* insteadxiaoming    10xiaohong    12xiaoli  13xiaowang    11lucy    21lily    22

4.第三方工具,sqoop

0 0
原创粉丝点击