hive库基础命令
来源:互联网 发布:罗尼库尔曼数据深蹲 编辑:程序博客网 时间:2024/06/04 00:26
创建数据库
hive> create database base1;
使用数据库
hive> use base1;
创建表
hive> create table table1(cols string,cols1 string);
创建一个表与当前hive存在的表结构一样
hive> create table table1 like table2;
创建分区表
hive> create table table1(cols string,cols2 string) partitioned by (cols3 string,cols4 string);
加载分区表数据
hive> load data local inpath ‘/home/hadoop/input/hive/partitions/file1’ into table table1 partition (cols=’1998-01-01’,cols1=’SZ’);
从本地文件加载数据
hive> load data local inpath ‘/d:/123/123.txt’ overwrite into table table1;
展示表中分区
hive> show partitions table1;
展示所有数据库
hive> show databases;
展示所有表
hive> show tables;
展示后缀为S的表
hive> show table’.*s’;
显示表结构
hive> describe table1;
重命名表名称
hive> alter table tables1 rename to table2;
添加新一列
hive> alter table table1 add columns (other string comment ‘其他’);
删除表
hive> drop table table1;
删除表且保持表结构表定义
hive> dfs -rmr /home/hive/base1/table1;
显示所有函数
hive> show functions;
查看函数用法
hive> describe function xx;
查看数组,map,结构
hive> select cols[0],cols1[‘a’],cols.b from complex;
内连接
hive> select sales.,things. from sales join things on (sales.id = things.id);
外连接
hive> selectsales.*,things.*from sales left outer join things on(sales.id = things.id);
hive> select sales., things. fromsales right outer join things on(sales.id = things.id);
hive> select sales., things. Fromsales full outer join things on(sales.id = things.id);
in查询
hive> select * from thingsleft semi join sales on (sales.id = things.id);
map连接(hive可以把较小的表放入每个mapper的内存来执行连接)
insertoverwrite table ..select:新表预先存在
hive> from records2
insert overwritetable stations_by_year select year,count(distinct station) group by year
insert overwrite table records_by_year select year,count(1) groupby year
insert overwrite table good_records_by_year selectyear,count(1) where temperature != 9999 and (quality = 0 or quality = 1 orquality =4 or quality = 5 or quality = 9) group by year;
create table … as select:新表表预先不存在
hive>create table target as select cols1,cols2 from source;
创建视图
hive> create view valid_records as select *from records2 where temperature!=9999;
查看视图详细信息
hive> describe extended valid_records;
查看hive为某个查询使用多少个mapreduce作业
hive> explain select sales.*, things.*from sales join things on (sales.id =things.id);
- hive库基础命令
- hive基础命令
- hive基础命令
- hive基础命令
- Hive 基础命令和 TPC-H Benchmark
- hive 命令
- hive 命令
- Hive命令
- Hive 命令
- hive命令
- hive 命令
- hive命令
- hive命令
- Hadoop下hive数据库基础操作命令代码合集
- hive基础
- Hive基础
- hive基础
- Hive基础
- 30-CSS-05-CSS(伪元素选择器_1)
- 逃离迷宫 HDU杭电1728 【BFS】
- 关于addSubView需要注意的几个点
- erlang学习之基础语法
- Where to fast and safe cheap swtor credits within 3-28 minutes
- hive库基础命令
- hdoj 1429 胜利大逃亡(续) 【BFS + 状态压缩】
- html学习笔记(14)
- tomcat+redis共享session setAttribute报错
- 30-CSS-06-CSS(伪元素选择器_2)
- Eclipse操作hive数据库以及操作HDFS的jar包和环境配置
- 手机网页中输入框被输入法遮挡问题
- 费舍尔方法
- SwipeRefreshLayout 上拉加载与下拉刷新