博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hive 字段名称显示
阅读量:6923 次
发布时间:2019-06-27

本文共 2585 字,大约阅读时间需要 8 分钟。

首先查看一个sql

1、首先存在一个数据表tmp

CREATE  TABLE tmp(  platform string,   channel string,   chan_value string,   uid string,   host int,   logtime string,   bd_source string,   action string,   refer string,   back_url string,   browser string,   mobile string,   server_ip string,   ip string,   url string,   post string,   handle_time string,   logday string)

2、查看这个表的数据

hive> select * from tmp limit 2;OKadr    partner    touch.qunar.com    -    4    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117adr    partner    touch.qunar.com    -    0    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117Time taken: 2.549 seconds, Fetched: 2 row(s)

这个数据十分不可读,那么就希望能格式化这些数据

3、set hive.cli.print.header=true; // 打印列名

hive> select * from tmp limit 2;     OKplatform    channel    chan_value    uid    host    logtime    bd_source    action    refer    back_url    browser    mobile    server_ip    ip    url    post    handle_time    logdayadr    partner    touch.qunar.com    -    4    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117adr    partner    touch.qunar.com    -    0    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117Time taken: 0.218 seconds, Fetched: 2 row(s)

上面增加了列名

4、set hive.cli.print.row.to.vertical=true; // 开启行转列功能, 前提必须开启打印列名功能

5、set hive.cli.print.row.to.vertical.num=1; // 设置每行显示的列数

------------------这两步暂时没有生效,是xml文件设置的问题---------

转载地址:http://lykjl.baihongyu.com/

你可能感兴趣的文章
11.22 访问日志不记录静态文件 11.23 访问日志切割 11.24 静态元素过期时间
查看>>
Bash脚本语法泛述
查看>>
SSH打通密钥后仍需要密码
查看>>
GZIP(1)
查看>>
在线压缩解压缩PHP代码
查看>>
使用vmware vdp备份2008虚机时,如果出错可以参考这篇文章。
查看>>
新网互联域名注册量动态:6月下旬净增3341个
查看>>
一台服务器的黑道生涯之六 保安来了
查看>>
LINUX的交换分区或交换文件SWAP的查看与维护
查看>>
Nacos 发布0.3.0版本,迄今为止最好看的版本
查看>>
使用NAS动态存储卷创建有状态应用
查看>>
细说select、poll和epoll之间的区别与优缺点
查看>>
TypeScript + Vue 传统多页面开发模式配置方案
查看>>
About Me
查看>>
Android Studio 错误 Duplicate files copied in APK META-INF/xxxx
查看>>
PHP验证码
查看>>
如何应对系统蓝屏
查看>>
好程序员分享如何看待CSS中BEM的命名方式?
查看>>
Linux 使用xl2tpd搭建l2tp ***服务
查看>>
基础知识
查看>>