4、后台启动hiveserver2
[root@hop01 hive1.2]# bin/hiveserver2 &
5、Jdbc连接测试
[root@hop01 hive1.2]# bin/beelineBeeline version 1.2.1 by Apache Hivebeeline> !connect jdbc:hive2://hop01:10000Connecting to jdbc:hive2://hop01:10000Enter username for jdbc:hive2://hop01:10000: hiveroot (账户回车)Enter password for jdbc:hive2://hop01:10000: ******(密码123456回车)Connected to: Apache Hive (version 1.2.1)Driver: Hive JDBC (version 1.2.1)0: jdbc:hive2://hop01:10000> show databases;+----------------+--+| database_name|+----------------+--+| default|+----------------+--+
四、高级查询语法1、基础函数
select count(*) count_user from hv_user;select sum(age) sum_age from hv_user;select min(age) min_age,max(age) max_age from hv_user;+----------+----------+--+| min_age| max_age|+----------+----------+--+| 23| 25|+----------+----------+--+
2、条件查询语句
select * from hv_user where name='test-user' limit 1;+-------------+---------------+--------------+--+| hv_user.id| hv_user.name| hv_user.age|+-------------+---------------+--------------+--+| 1| test-user| 23|+-------------+---------------+--------------+--+select * from hv_user where id>1 AND name like 'dev%';+-------------+---------------+--------------+--+| hv_user.id| hv_user.name| hv_user.age|+-------------+---------------+--------------+--+| 2| dev-user| 25|+-------------+---------------+--------------+--+select count(*) count_name,name from hv_user group by name;+-------------+------------+--+| count_name|name|+-------------+------------+--+| 1| dev-user|| 1| test-user|+-------------+------------+--+
3、连接查询
select t1.*,t2.* from hv_user t1 join hv_dept t2 on t1.id=t2.dp_id;+--------+------------+---------+-----------+-------------+--+| t1.id|t1.name| t1.age| t2.dp_id| t2.dp_name|+--------+------------+---------+-----------+-------------+--+| 1| test-user| 23| 1| 技术部|+--------+------------+---------+-----------+-------------+--+
【数据仓库组件:Hive环境搭建和基础用法】
推荐阅读
- 2020年Web Apps用户界面发展趋势:组件统治一切
- 常用的10种MySQL函数,数据处理一定用得上
- Index MySQL查询合理使用索引:别让你的数据库负重前行
- JavaScript的两大类内建数据类型
- 数据库:SQLServer分页查询整理
- MySQL分组查询后如何获取每组的前N条数据,你会吗?
- 5大常用MySQL客户端工具,入门数据库必备收藏
- 面试被问:JDBC底层是如何连接数据库的?
- 清除数据后照片还在吗?
- mysql误删数据恢复