Accessing HIVE via Beeline:
Starting beeline client
beeline --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.
Connecting to hive2 server
!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: *********
Setting Your Queue (if any)
set mapred.job.queue.name=<your queue name>;
Note: You need to set a queue in order to run queries.
Setting Your Database
USE google_map_data;
Note: You should be in a database when executing queries.
Reconnecting an inactive session
!reconnect jdbc:hive2:// silver-server-hive.app.google.com:10000/default;
Quitting beeline client
!quit
Notes:
- Loading beeline, the URL and providing your username & password in one command:
beeline -u jdbc:hive2:// silver-server-hive.app.google.com:10000
-n <yourname> -p <yourpassword> --incremental=true**
Basic Beeline Queries
Beeline supports a rich set of SQL query functions.
Getting Information About Data
SHOW DATABASES;
USE <database>;
SHOW TABLES;
DESC <table>;
DESC FORMATTED <table>;
Simple limited select statements
SELECT * FROM google_map_city limit 25;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…