[hadoop@node1 ~]$ hive -help
usage: hive
-d,--define <key=value> Variable subsitution to apply to hive
commands. e.g. -d A=B or --define A=B
--database <databasename> Specify the database to use
-e <quoted-query-string> SQL from command line
-f <filename> SQL from files
-H,--help Print help information
--hiveconf <property=value> Use value for given property
--hivevar <key=value> Variable subsitution to apply to hive
commands. e.g. --hivevar A=B
-i <filename> Initialization SQL file
-S,--silent Silent mode in interactive shell
-v,--verbose Verbose mode (echo executed SQL to the
console)
1.1 hive -e
[hadoop@node1 ~]$ hive -e "select * from test_hive.student"
ls: cannot access /home/hadoop/apps/spark-2.2.2-bin-2.6.0-cdh5.7.0/lib/spark-assembly-*.jar: No such file or directory
2019-01-16 16:26:45,432 WARN [main] mapreduce.TableMapReduceUtil: The hbase-prefix-tree module jar containing PrefixTreeCodec is not present. Continuing without it.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/apps/hbase-1.2.0-cdh5.7.0/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/apps/hadoop-2.6.0-cdh5.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2019-01-16 16:26:45,537 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Logging initialized using configuration in file:/home/hadoop/apps/hive-1.1.0-cdh5.7.0/conf/hive-log4j.properties
OK
student.id student.name
1001 MIke
1002 John
1003 Mary
Time taken: 0.885 seconds, Fetched: 3 row(s)
1.2 hive -f
[hadoop@node1 ~]$ hive -f hive-f.sql
ls: cannot access /home/hadoop/apps/spark-2.2.2-bin-2.6.0-cdh5.7.0/lib/spark-assembly-*.jar: No such file or directory
2019-01-16 16:33:04,037 WARN [main] mapreduce.TableMapReduceUtil: The hbase-prefix-tree module jar containing PrefixTreeCodec is not present. Continuing without it.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/apps/hbase-1.2.0-cdh5.7.0/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/apps/hadoop-2.6.0-cdh5.7.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2019-01-16 16:33:04,162 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Logging initialized using configuration in file:/home/hadoop/apps/hive-1.1.0-cdh5.7.0/conf/hive-log4j.properties
OK
student.id student.name
1001 MIke
1002 John
1003 Mary
Time taken: 0.834 seconds, Fetched: 3 row(s)
[hadoop@node1 ~]$ cat .hivehistory
CREATE TEMPORARY VIEW parquetTable
USING org.apache.spark.sql.parquet
OPTIONS (
path "/home/hadoop/apps/spark-2.1.3-bin-2.6.0-cdh5.7.0/examples/src/main/resources/users.parquet"
);
show tables;
select * from parquettable;
use default
;
show databases;
use default;
create table bf_log(ip string,user string,requesturl string);
show tables;
desc bf_log;
select count(*) from bf_log;
create table student(id int,name string) ROW FORMAT DELIMITED FIELDS
TERMINATED BY '\t';
show tables;
load data local inpath 'home/hadoop/student.txt' into table student;
load data local inpath '/home/hadoop/student.txt' into table student;
select * from student;
select id from student;
show databases;
create database test_hive;
show databases;
ues test_hive;
use test_hive;
create table student(id int,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
show tables;
desc student;
desc extended student;
desc fromatted student;
desc formatted student;
load data local inpath '/home/hadoop/student.txt' into table test_hive.student;
show functions;
desc function upper;
desc function extended upper;
select id,upper(name) uname from test_hive.student;