-
set hive.cli.print.header=true; // 打印列名
-
set hive.cli.print.row.to.vertical=true; // 开启行转列功能, 前提必须开启打印列名功能
-
set hive.cli.print.row.to.vertical.num=1; // 设置每行显示的列数
或者
If you use HiveServer2 (Hive > 0.14), you can use "beeline" shell and there is "vertical
" option.
0: jdbc:hive2://127.0.0.1:10000> !set outputformat table 0: jdbc:hive2://127.0.0.1:10000> select * from sample_07 limit 1; +-----------------+------------------------+----------------------+-------------------+ | sample_07.code | sample_07.description | sample_07.total_emp | sample_07.salary | +-----------------+------------------------+----------------------+-------------------+ | 00-0000 | All Occupations | 134354250 | 40690 | +-----------------+------------------------+----------------------+-------------------+ 1 row selected (0.131 seconds) 0: jdbc:hive2://127.0.0.1:10000> !set outputformat vertical 0: jdbc:hive2://127.0.0.1:10000> select * from sample_07 limit 1; sample_07.code 00-0000 sample_07.description All Occupations sample_07.total_emp 134354250 sample_07.salary 40690 1 row selected (0.063 seconds) 0: jdbc:hive2://127.0.0.1:10000>
转载请注明:学时网 » Hive query results in vertical format like MySQL’s “\G”? 开启列展示