hive 使用方法--小工具(二)

来源:互联网 发布:韩宜淘宝旗舰店 编辑:程序博客网 时间:2024/05/18 23:12

1、小工具:

  • desc student; 描述表
  • desc extended student ; 查看表的详细信息(表的类型(内部表、外部表),表压缩否)
  • desc formatted student ; 格式化输出表信息
  • show create table student ;查看建表语句
  • show functions ; 查看hive中的函数
  • desc function upper; 描述函数
  • desc function extended upper; 描述方法具体使用方法
  • show tables; 查看所有的表
  • show databases; 查看所有的数据库
  • set hive.cli.print.header =true 设置参数,临时生效
  • minimal 是否跑mapreduce可配

2、帮助信息 (在shell中的help)

bin/hive -help 一个横杠

[root@yeemi01 hive-0.13.1-cdh5.3.6]# bin/hive -helpusage: hive -d,--define <key=value>          Variable subsitution to apply to hive                                  commands. e.g. -d A=B or --define A=B    --database <databasename>     Specify the database to use -e <quoted-query-string>         SQL from command line -f <filename>                    SQL from files -H,--help                        Print help information -h <hostname>                    connecting to Hive Server on remote host    --hiveconf <property=value>   Use value for given property    --hivevar <key=value>         Variable subsitution to apply to hive                                  commands. e.g. --hivevar A=B -i <filename>                    Initialization SQL file -p <port>                        connecting to Hive Server on port number -S,--silent                      Silent mode in interactive shell -v,--verbose                     Verbose mode (echo executed SQL to the                                  console)* bin/hive -e "select * from student" >> test.log  //加双引号,多条Hql用分号分割,可不用开启hive,在脚本执行;* bin/hive -f hive.sql ; //执行文件,在文件中写入多个Hql。* bin/hive --hiveconf    //添加参数,key-value对形式,对当前创库有效(相当于在配置文件中设置配置项);  --》一般用于测试,不会影响集群中其他的进程*  bin/hive -d  default  指定默认进入default数据库* 

bin/hive - -help (两个横杠,中间没空格)

[root@yeemi01 hive-0.13.1-cdh5.3.6]# bin/hive --helpUsage ./hive <parameters> --service serviceName <service parameters>    Service List: beeline cli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool version Parameters parsed:  --auxpath : Auxillary jars   --config : Hive configuration directory  --service : Starts specific service/component. cli is defaultParameters used:  HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory  HIVE_OPT : Hive optionsFor help on a particular service:  ./hive --service serviceName --helpDebug help:  ./hive --debug --help

3、临时添加配置项:

命令行启动hive时,用--hiveconf hive.cli.print.header = true 进入hive,执行 set hive.cli.print.header = true;

4、 访问本地/hdfs

  • 访问本地 : ! ls / –>用叹号
  • 访问hdfs : dfs -ls / –>不需要再去找namenode入口,直接去对hdfs进行操作,比用hdfs的dfs 命令快,性能消耗主要在启动进程上。