1. Two modes of this article command:
Interactive mode, the shell environment for hive:hive > ....
Non-interactive mode: normal Linux command mode :% ... ..
2.Hive Shell Common operations
1) Hive-e: Executes the specified HQL from the command line and does not require a semicolon :
% hive-e ' select * from dummy ' > a.txt
2) hive–f: Execute hql Script
% hive-f/home/my/hive-script.sql
3) Hive-i: Executes the initialization SQL file before entering interactive mode
% Hive-i/home/my/hive-init.sql
4) hive-v: Output execution of the HQL statement to the console
5) hive-s: Display only running results, no additional information is displayed:
% hive-s-E ' select * from dummy '
Special commands in 3.Hive interactive mode:
Using a! Prefix to run the command that hosts the operating system, which is the Operation command for Linux. hive > a! ....
Use the DFS command to access the Hadoop file system, that is, to execute the Hadoop command. Hive > Dfs ....
4. Save Query Results
The first way:
% hive-e ' select * from dummy ' > a.txt
The second way:
hive > Insert overwrite local directory '/root/hive/a.txt ' select * from logs sort by TS;
5. Here is a method for generating a single-Line table:
% echo ' x ' >/tmp/dummy.txt
% hive-e "CREATE table dummy (value string); \
Load data local inpath '/tmp/dummy.txt ' overwrite into table dummy "
Local means copying files from the native Linux system to the '/user/hive/warehouse/' directory on the HDFS system.
overwrite means overwrite write, that is, delete the original file, and then write the local data. If this keyword is omitted, hive simply adds the new data file to the directory.
Hive Shell Common operations