vim /etc/profile
export HIVE_HOME=/export/servers/hive...
export PATH=:$HIVE_HOME/bin:$PATH

前台启动hive:
hive --service hiveserver2
客户端连接:
beeline
!connect jdbc:hive2://node03:10000

create database [if not exists] myhive location '/myhive2';
use myhive;
desc database myhive2;
desc database extended myhive2;
drop database myhive2 [cascade];

create table [if not exists] stu (sid string,sname string);

create table stu2 as select * from stu;
create table stu3 like stu;
desc [formatted] stu2;

create external table [if not exists] student (sid string,sname string,ssex string,sbirth string) partitioned by (year string,month string,day string) row format delimited fields terminated by '\t' stored as textfile location '/user/stu';

load data local inpath '/export/servers/hivedatas/score.csv' [overwrite] into table score;

load data inpath '/hivedatas/score.csv' into table score partition(year='2018',month='06',day='18');

insert overwrite table score5 partition(month='201801') select sid,sname,sscore from score; (注意不能使用select * from score,否则报错:Error: Error while compiling statement: FAILED: SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different ''201902'': Table insclause-0 has 3 columns, but query has 4 columns. (state=42000,code=10044))

select * from score where month='201806'
union all
select * from score where month='201807';

show partitions score;

alter table score add partition(month='201808') partition(month='201809') ;

alter table score drop partition(month='201809');

msck repair table score4;
==============================================
truncate table score6;(只能清空管理表)

from score
insert overwrite table score_fir partition(month='201806') select sid,cid
insert overwrite table score_sec partition(month='201806') select cid,sscore;

小结:create as select , insert select。

SELECT [ALL | DISTINCT] select_expr, select_expr, ...

FROM table_reference

[WHERE where_condition]

[GROUP BY col_list [HAVING condition]]

[CLUSTER BY col_list

| [DISTRIBUTE BY col_list] [SORT BY| ORDER BY col_list]

]

[LIMIT number]

select sid as myid, cid myid2 from score;

select count(distinct sid) from score;

select max(sscore),min(sscore),sum(sscore),avg(sscore) from score;

select * from score where sscore like '_9%';

select * from score where sscore rlike '9';

select sid,avg(sscore) from score group by sid;

select s_id ,avg(s_score) avgscore from score group by s_id having avgscore > 85;

select s.sid,s.sscore,stu.sname,stu.sbirth from score s left join student stu on s.sid = stu.sid;

select * from student s left | right | full [outer] join score b on s.sid = b.sid; 左右全 外连接

select sid, avg(sscore) avgScore from score group by sid order by sid, avgScore desc; 按照别名排序

set mapreduce.job.reduces=3;

select * from score sort by sscore;

insert overwrite local directory '/export/servers/hivedatas/sort'  row format delimited fields terminated by '\t' select * from score sort by sscore;

set mapreduce.job.reduces=7;

insert overwrite local directory '/export/servers/hivedatas/sort'  row format delimited fields terminated by '\t' select * from distribute by sid sort by sscore;

insert overwrite local directory '/export/servers/hivedatas/cluster' row format delimited fields terminated by '\t' select * from score cluster by sid;

bin/hive -hiveconf hive.root.logger=INFO,console

show functions;

show function [extended] split;

set hive.exec.compress.intermediate=true;
set mapreduce.map.output.compress=true;
set mapreduce.map.output.compress.codec= org.apache.hadoop.io.compress.SnappyCodec;
set hive.exec.compress.output=true;
set mapreduce.output.fileoutputformat.compress=true;
set mapreduce.output.fileoutputformat.compress.codec = org.apache.hadoop.io.compress.SnappyCodec;
set mapreduce.output.fileoutputformat.compress.type=BLOCK;

hive纯命令行的更多相关文章

  1. [Spark][Hive]Hive的命令行客户端启动:

    [Spark][Hive]Hive的命令行客户端启动: [training@localhost Desktop]$ chkconfig | grep hive hive-metastore 0:off ...

  2. 分区表,桶表,外部表,以及hive一些命令行小工具

    hive中的表与hdfs中的文件通过metastore关联起来的.Hive的数据模型:内部表,分区表,外部表,桶表受控表(managed table):包括内部表,分区表,桶表 内部表: 我们删除表的 ...

  3. hive在命令行消除进度等错误信息

    大家在使用shell脚本调用hive命令的时候,发现hive的中间过程竟然打印到错误输出流里面,这样在查看错误日志的时候,需要过滤这些没用的信息,那么可以使用如下的配置参数. set hive.ses ...

  4. Hive Beeline 命令行参数

    [hadoop@hive ~]$ beeline --help[中文版] The Beeline CLI 支持以下命令行参数: Option Description --autoCommit=[tru ...

  5. mvn从下载安装到纯命令行创建第一个mvn程序(编码,编译,测试,安装,打包)全过程细致分解

    1.maven的下载和安装: a.maven的下载注意事项:如果你是windows,请选择①号,如果你是linux,请选择②号,下载地址:http://maven.apache.org/downloa ...

  6. ubuntu进入纯命令行

    启动按shfit 然后光标在第一行按e 倒数第二行末尾添加quiet splash $vt_handoff 3 然后按CTRL+X或F10引导系统,启动之后就是命令行模式了

  7. mysql定时任务(数据库管理工具and 纯命令行)

    1.工具:Navicat 2.通过下列语句l爱查询event是否开启 打开Navicat命令列界面(点击工具可以看到或按F6) 输入下面命令 show variables like '%sche%'; ...

  8. 纯命令行的编辑利器:用好 awk 与 sed

    awk 的基本语法 awk 是模式查找与处理语言,是文本处理的利器.使用 awk 可以只用一条简单的命令完成复杂的文本数据处理. awk 命令的基本结构为: awk '模式 {处理}' 文件 比如,打 ...

  9. [hive] hive cli 命令行

    hive 版本 1.2.2 帮助信息 -d  属性 set   和 set -v 变量 hive --define    和  hivevar:变量名字 -e  不启动hive,执行完成后自动退出. ...

随机推荐

  1. 【Codeforces 915E】 Physical Education Lessons

    [题目链接] 点击打开链接 [算法] 线段树,注意数据量大,要动态开点 [代码] #include<bits/stdc++.h> using namespace std; ; ,root ...

  2. ChartCtrl源码剖析之——CChartGrid类

    CChartGrid类用来绘制波形区域中的表格,当绘制波形时波形就显示在这些表格上面.它处于该控件的区域,如下图所示: CChartGrid类的头文件. #if !defined(AFX_CHARTG ...

  3. rake db:migrate 与 bundle exec rake db:migrate 的区别(copy)

    [说明:资料来自http://blog.csdn.net/lihuan974683978/article/details/8715414] 之前一直没弄明白rake  db:migrate 与 bun ...

  4. 反编译Android的apk包得到源码(使用工具:dex2jar和jd-gui)

    1. 先从 http://download.csdn.net/detail/dingyuming1991/9618125 下载反编译工具dex2jar和jd-gui(当然也可以google搜索下载): ...

  5. CodeForces 723C Polycarp at the Radio (题意题+暴力)

    题意:给定 n 个数,让把某一些变成 1-m之间的数,要改变最少,使得1-m中每个数中出现次数最少的尽量大. 析:这个题差不多读了一个小时吧,实在看不懂什么意思,其实并不难,直接暴力就好,n m不大. ...

  6. zoj 2532 Internship【最小割】

    就是求哪些边在最大流上满流,也就是找割边.把0作为t点,s向所有的1~n连流量为inf的边,其他的边按照流量连.跑一遍最大流,从s顺着有残余流量的正向边dfs打标记fr,从t顺着正向边有残余流量的反向 ...

  7. vs2013 安装 mvc5 的方法

    工具-->NuGet程序包管理器-->程序包管理器控制台 然后 PM>Install-Package Microsoft.AspNet.Mvc -Version 5.0.0

  8. 《Windows核心编程系列》十一谈谈Windows线程池

    Windows线程池 上一篇博文我们介绍了IO完成端口.得知IO完成端口可以非常智能的分派线程.但是IO完成端口仅对等待它的线程进行分派,创建和销毁线程的工作仍然需要我们自己来做. 我们自己也可以创建 ...

  9. Fools and Roads CodeForces - 191C

    Fools and Roads CodeForces - 191C 题意:给出一棵n个节点的树,还有树上的k条简单路径(用路径的两个端点u和v表示),对于树上每一条边,求出其被多少条简单路径经过. 方 ...

  10. 洛谷 P2042 维护数列

    http://blog.csdn.net/drazxlnddt/article/details/51051598 flip为true表示以当前节点为根的子树需要交换.set为true表示以当前节点为根 ...