设为首页 加入收藏

TOP

hive基础知识(二)
2018-11-13 14:55:47 】 浏览:47
Tags:hive 基础知识

hive使用场景:

离线数据

处理大数据

延迟高

数据的离线处理;比如:日志分析,海量结构化数据离线分析…

Hive的执行延迟比较高,因此hive常用于数据分析的,对实时性要求不高的场合;

Hive优势在于处理大数据,对于小数据没有优势,因为Hive的执行延迟比较高。

hive优点:

操作接口采用类SQL语法,提供快速开发的能力(简单、容易上手);

避免了去写MapReduce,减少开发人员的学习成本;

统一的元数据管理,可与impala/spark等共享元数据;

易扩展(HDFS+MapReduce:可以扩展集群规模;支持自定义函数);

数据分析师交流群:283296032

hive具体操作:

1、查看数据库:

show databases;

2、创建数据库:

create database if not exists a;

3、查看数据库信息:

describe databases a;

hive> describe database a;

OK

a hdfs://host-10-10-10-17:6200/user/hive/warehouse/a.dbhadoopUSER

Time taken: 0.034 seconds, Fetched: 1 row(s)

hive> desc database a;

-------同上面一样


4、使用数据库、查看表

hive> use a;

OK

Time taken: 0.014 seconds

hive> show tables;

OK

Time taken: 0.058 seconds

5、设置数据库名的显示

hive> set hive.cli.print.current.db=true;

$ bin/hive --hiveconf hive.cli.print.current.db=true;

6、建表

hive (a)> create table if not exists student(id int,name string) row format delimited fields terminated by '\t' stored as textfile;

OK

Time taken: 0.131 seconds

7、加载数据

cd /home/hadoop/

ls

cd datas

pwd 打印当前目录

rz 上传文件

[hadoop@host-10-10-10-186 datas]$ rz

hive (a)> insert into table student(id,name) values(100,'zhang');

确定文件的位置:

/home/hadoop/datas/student.tsv

hive (a)> load data local inpath '/home/hadoop/datas/student.tsv' into table student;

hive (a)> select * from student;

8、

设置显示表头:

hive (a)> set hive.cli.print.header=true;

hive (a)> select * from student;

不显示表头:

hive (a)> set hive.cli.print.header=false;

9、

查看文件具体信息

$ cat student.tsv

删除:

rm -rf student.tsv

操作流程:

首先建表:

hive (a)>create table if not exists student(id int,name string) row format delimited fields terminated by '\t' stored as textfile;

$ cd /home/hadoop/

$ ls

$ cd datas

$ ls

$ cat student.tsv

(在本地数据上传:$ rz :已上传,不用操作)

$ pwd

显示的结果:

eg:不是绝对的,看你自己的目录就可以了

/home/hadoop/datas

hive (a)>load data local inpath '/usr/local/apache-hive-1.2.1-bin/student.tsv' into table student;

hive (a)> select * from student;

hive (a)> set hive.cli.print.header=true;

可视化工具:hue

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇hive变量调用 hive和shell hdfs命.. 下一篇在hadoop集群上安装hive和mysql

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目