每日日报2021 11/7

今天我准备学习hive的基础操作:

 
[atguigu@hadoop102 hive]$ bin/hive -help
usage: 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
--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
-S,--silent Silent mode in interactive shell
-v,--verbose Verbose mode (echo executed SQL to the
console)
1)“
-e”不进入 hive 的交互窗口执行 sql 语句
[atguigu@hadoop102 hive]$ bin/hive -e "select id from student;"
2)“
-f”执行脚本中 sql 语句
1)在/opt/module/hive/下创建 datas 目录并在 datas 目录下创建 hivef.sql 文件
[atguigu@hadoop102 datas]$ touch hivef.sql
2)文件中写入正确的 sql 语句
select *from student;
3)执行文件中的 sql 语句
[atguigu@hadoop102 hive]$ bin/hive -f /opt/module/hive/datas/hivef.sql
4)执行文件中的 sql 语句并将结果写入文件中
[atguigu@hadoop102 hive]$ bin/hive -f /opt/module/hive/datas/hivef.sql >
/opt/module/datas/hive_result.txt
2.8 Hive 其他命令操作
posted @ 2021-11-07 20:52  宋振兴  阅读(33)  评论(0编辑  收藏  举报