首先查看一个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 ;
OK
adr partner touch.qunar.com - :: - 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 20141117
adr partner touch.qunar.com - :: - 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 20141117
Time taken: 2.549 seconds, Fetched: row(s)
这个数据十分不可读,那么就希望能格式化这些数据
3、set hive.cli.print.header=true; // 打印列名
hive> select * from tmp limit ;
OK
platform channel chan_value uid host logtime bd_source action refer back_url browser mobile server_ip ip url post handle_time logday
adr partner touch.qunar.com - :: - 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 20141117
adr partner touch.qunar.com - :: - 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 20141117
Time taken: 0.218 seconds, Fetched: row(s)
上面增加了列名
4、set hive.cli.print.row.to.vertical=true; // 开启行转列功能, 前提必须开启打印列名功能
5、set hive.cli.print.row.to.vertical.num=1; // 设置每行显示的列数
------------------这两步暂时没有生效,是xml文件设置的问题---------