HIVE的启动及基本命令

Hive基本操作

(1)启动hive

[atguigu@hadoop102 hive]$ bin/hive

(2)查看数据库

hive> show databases;

(3)打开默认数据库

hive> use default;

(4)显示default数据库中的表

hive> show tables;

(5)创建一张表

hive> create table student(id int, name string);

(6)显示数据库中有几张表

hive> show tables;

(7)查看表的结构

hive> desc student;

(8)向表中插入数据

hive> insert into student values(1000,"ss");

(9)查询表中数据

hive> select * from student;

(10)退出hive

hive> quit;

Hive实际操作

(1)启动hive

[atguigu@hadoop102 hive]$ bin/hive

(2)显示数据库

hive> show databases;

(3)使用default数据库

hive> use default;

(4)显示default数据库中的表

hive> show tables;

(5)删除已创建的student表

hive> drop table student;

(6)创建student表, 并声明文件分隔符’ ’

hive> create table student(id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED

 BY ' ';

(7)加载/opt/module/datas/student.txt 文件到student数据库表中。

hive> load data local inpath '/opt/module/datas/student.txt' into table student;

(8)Hive查询结果

hive> select * from student;

OK

1001   zhangshan

1002   lishi

1003   zhaoliu

Time taken: 0.266 seconds, Fetched: 3 row(s)

原文地址:https://www.cnblogs.com/fengchuiguobanxia/p/15346361.html