目录

  • ​​hive outline​​
  • ​​1 必须启动hdfs和yarn​​
  • ​​2 启动hive​​
  • ​​3 查看数据库​​
  • ​​4 使用数据库​​
  • ​​5 在默认数据库中创建一张表​​
  • ​​6 查看表的结构​​
  • ​​7 向表中插入数据​​
  • ​​8 查询表中数据​​
  • ​​9 退出hive​​

hive outline

​​链接​​

1 必须启动hdfs和yarn

因为hive底层跑的是mr

​分布式节点要注意配置hdfs和yarn的位置​​ 位置不同,启动节点不同

[hadoop@hadoop202 hadoop-2.7.2]$ sbin/start-dfs.sh 
[hadoop@hadoop203 hadoop-2.7.2]$ sbin/start-yarn.sh

​注意:​​配置了zookeeper的话,zk 也要启动

2 启动hive

[hadoop@hadoop202 hive-1.2.1]$ bin/hive

3 查看数据库

hive> show databases;

4 使用数据库

hive> use default;

5 在默认数据库中创建一张表

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

6 查看表的结构

hive> desc student;

7 向表中插入数据

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

8 查询表中数据

hive> select * from student;

9 退出hive

hive> quit;