HIVE之查缺补漏
Hive常用交互命令
- “-e”不进入hive的交互窗口执行sql语句
bin/hive -e "select id from student;"
- “-f”执行脚本中sql语句
-- 在/opt/module/datas目录下创建hivef.sql文件
touch hivef.sql
--文件中写入正确的sql语句
select *from student;
--执行文件中的sql语句
[atguigu@hadoop102 hive]$ bin/hive -f /opt/module/datas/hivef.sql
--执行文件中的sql语句并将结果写入文件中
[atguigu@hadoop102 hive]$ bin/hive -f /opt/module/datas/hivef.sql > /opt/module/datas/hive_result.txt
hive配置显示数据库名和表字段
在hive-site.xml文件中添加如下配置信息,就可以实现显示当前数据库,以及查询表的头信息配置。
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
高阶建表语句
- CTAS(复制表结构和数据):
create table 表1 as select * from 表2;
- CTAS(复制表结构):
create table 表1

本文详细介绍了Hive的各种高级操作,包括交互命令、配置显示数据库和表信息、高阶建表语句、类型转换、数据库管理、表的操作、数据导入导出以及查询和调优技巧。此外,还探讨了窗口函数的使用,强调了Hive查询的灵活性和性能优化的重要性。
最低0.47元/天 解锁文章
4282

被折叠的 条评论
为什么被折叠?



