- 上传hive apache-hive-1.0.1-bin.tar.gz
- 解压tar -zxvf apache-hive-1.0.1-bin.tar.gz
- 改名mv apache-hive-1.0.1-bin hive
- cd hive
- 执行bin/hive进入hive 命令行模式,需hadoop集群已配置好
show databases;–查看数据库
show tables;–>查看表
create database test;–>创建一个库
use test;–>切换使用的数据库
create table student_user(id int,name string);–>创建表
show create table student_user;–>显示创建表的信息。
外部创建一个文件:test.txt,内容如下:
1 zhangSan
2 liSIload data local inpath ‘/usr/local/java/data/test.txt’ into table student_user; –>长传文件【可在hdfs上进行查看】
select * from student_user;【查出来是null是因为没有指定分隔符】
create table if not exists teacher(id bigint,name string) row format delimited fields terminated by ‘\t’ stored as textfile;
指定分隔符创建
load data local inpath ‘/usr/local/java/data/test.txt’ into table teacher;
select * from teacher;可查看到数据
select count(0) from teacher;–>会生成mapperreduce进行作业得到返回值
hive的安装及初体验
最新推荐文章于 2022-02-21 15:36:41 发布