且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 Beeline 连接到 Hive

更新时间:2022-10-31 15:49:27

通过 Beeline 访问 HIVE:

启动直线客户端

beeline --incremental=true

注意:命令行选项-incremental=true"是可选的,但会延长您可以保持空闲状态并且不会断开连接的时间.

Note: The command line option "—incremental=true" is optional, but will extend the amount of time that you can remain idle and not have your connection dropped.

!connect jdbc:hive2://silver-server-
hive.app.google.com:10000/default

注意:系统将提示您输入用户名 &密码.使用用户名和密码

Note: You will be prompted for your username & password. USE user name and Password

beeline> !connect jdbc:hive2:// silver-server-hive.app.google.com:10000/default
scan complete in 3ms
Connecting to jdbc:hive2:// silver-server-hive.app.google.com:10000/default
Enter username for jdbc:hive2:// silver-server-hive.app.google.com:10000/default:suman
Enter password for jdbc:hive2:// silver-server-hive.app.google.com:10000/default: *********

设置您的队列(如果有)

set mapred.job.queue.name=<your queue name>; 

注意:您需要设置一个队列才能运行查询.

Note: You need to set a queue in order to run queries.

USE google_map_data;

注意:执行查询时,您应该在数据库中.

Note: You should be in a database when executing queries.

!reconnect jdbc:hive2:// silver-server-hive.app.google.com:10000/default; 

退出直线客户端

!quit

注意事项:

  • 加载直线、URL 并提供您的用户名 &一个命令中的密码:

beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000 
-n <yourname> -p <yourpassword> --incremental=true**

基本直线查询

Beeline 支持丰富的 SQL 查询功能.

Basic Beeline Queries

Beeline supports a rich set of SQL query functions.

SHOW DATABASES;
USE <database>;

SHOW TABLES;
DESC <table>;
DESC FORMATTED <table>;

简单的有限选择语句

SELECT * FROM google_map_city limit 25;