【云计算】查询hivesql结果保存hdfs或者本地操作教程
小标 2018-12-13 来源 : 阅读 1285 评论 0

摘要:本文主要向大家介绍了【云计算】查询hivesql结果保存hdfs或者本地操作教程,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。

本文主要向大家介绍了【云计算】查询hivesql结果保存hdfs或者本地操作教程,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。


查询hive sql 结果保存hdfs 或者本地操作如下


本地


insert overwrite local directory "/tmp/zhuqinghua"


select user, login_time from user_login;


select userid ,count(*), num from bi.test where date_time = '2018-01-01' group by date_time,userid order by num desc limit 10;


hdfs


insert overwrite directory "/tmp/zhuqinghua"


select user, login_time from user_login;


select userid ,count(*), num from bi.uniuserride_by_city_daily where date_time = '2018-01-01' group by date_time,userid order by num desc limit 10;


/etc/init.d/hive-server2 status


/etc/init.d/hive-server2 stop


/etc/init.d/hive-server2 start


hive>create database database_name;创建数据库


hive>creat database if not exists database_name


hive> show databases; 查看数据库


hive> show databases like 'h.*';如果数据库比较多的话,也可以用正则表达式来查看:


hive> use default; --使用哪个数据库


hive>show tables; --查看该数据库中的所有表


hive>show tables ‘*t*’; --支持模糊查询


hive> describe tab_name; --查看表的结构及表的路径


hive> describe database database_name; --查看数据库的描述及路径


hive> drop database if exists database_name; --删除空的数据库


hive> drop database if exists database_name cascade; --先删除数据库中的表再删


hive>show partitionst1; --查看表有哪些分区


hive>alter table table_name rename to another_name; --修改表名


hive>drop tablet1; --删除表t1


hive> drop table if exists t1;


hive不支持修改表中数据,但是可以修改表结构,而不影响数据


有local的速度明显比没有local慢:


hive>load data inpath '/root/inner_table.dat' into table t1; 移动hdfs中数据到t1表中


hive>load data local inpath '/root/inner_table.dat' into table t1; 上传本地数据到hdfs中


load data local inpath '${env:HOME}/目录'overwrite into table table_namepartition (分区);


创建表ORC压缩存储


create table if not exists record_orc ( rid STRING,


uid STRING,


bid STRING,


price INT,


source_province STRING, target_province STRING, site STRING, express_number STRING, express_company STRING, trancation_date DATE


)


stored as orc;


insert into table record_orc select * from record;


          

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标大数据云计算大数据安全频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved