<!-- 数据默认的存储位置(HDFS) --> <property> <name>hive.metastore.warehouse.dir</name> <value>/user/hive/warehouse</value> <description>location of default database for the warehouse</description> </property>
显示当前库
1 2 3 4 5 6
<!-- 在命令行中,显示当前操作的数据库 --> <property> <name>hive.cli.print.current.db</name> <value>true</value> <description>Whether to include the current database in the Hive prompt.</description> </property>
<!-- 操作小规模数据时,使用本地模式,提高效率 --> <property> <name>hive.exec.mode.local.auto</name> <value>true</value> <description>Let Hive determine whether to run in local mode automatically</description> </property>
# 在命令行检查参数值设置是否生效 hive> set hive.exec.mode.local.auto;
用户自定义配置文件(hive-site.xml、hive-default.xml)
默认配置文件:hive-default.xml
用户自定义配置文件:hive-site.xml
配置文件的设定对本机启动的所有Hive进程有效;
Hive命令
基础命令
1 2 3 4 5 6 7 8 9 10 11 12 13
hive -help
usage: hive -d,--define <key=value> Variable substitution 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 --hiveconf <property=value> Use value for given property --hivevar <key=value> Variable substitution to apply to Hive commands. e.g. --hivevar A=B -i <filename> Initialization SQL file -S,--silent Silent mode in interactive shell -v,--verbose Verbose mode (echo executed SQL to the console)
-e:不进入hive交互窗口,执行sql语句
1
hive -e "select * from users"
-f:执行脚本中sql语句
1 2 3 4 5 6
# 创建文件hqlfile1.sql,内容:select * from users # 执行文件中的SQL语句 hive -f hqlfile1.sql