美文网首页笔记本📒
hive基本操作笔记

hive基本操作笔记

作者: 涓涓自然卷 | 来源:发表于2020-04-03 17:19 被阅读0次

一、几种操作方式:

1、文件内容:

[root@master tmp]# vi hive_citys.sql
1 select distinct city from talentdata.data_cleared_11;

2、hive -f 操作:

[root@master tmp]# hive -f /data/weixiujuan/tmp/hive_citys.sql >> cleared_distinct_citys.txt

3、 hive -e 操作:

hive -e "select user, login_timestamp from user_login" > /tmp/out.txt
[root@master data]# hive -e "select count(*) from talentdata.data_cleared_00" > /data/weixiujuan/data/out_0118.txt

4、hive窗口里操作:

hive> insert overwrite local directory "/tmp/out/" row format delimited fields
terminated by "\t" select user, login_time from user_login;

5、hive执行sql脚本:

hive> source /usr/apache-kylin-2.4.1-bin/create_sample_tables.sql

6、hive执行linux命令:

hive> ! ls /data/juan/data;

二、基本命令:

1、hive导出到本地:

hive> INSERT OVERWRITE LOCAL DIRECTORY '/home/hadoop/output' ROW FORMAT DELIMITED FIELDS TERMINATED by ',' select * from testA;

2、建表:

drop table tomcatLog_wxj;
create external table tomcatLog_wxj(
client_ip string, request_method string,
uri string,
server_protol string,
time string,
time_zone string,
flag string
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ' '
location 'hdfs://cdh1:8020/user/hive/warehouse/flume/tomcat_log'

3、索引:

// 创建索引
create index index_data_cleared_00_exe_time on table data_cleared_00(exe_time)
as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'
with deferred rebuild
IN TABLE index_table_data_cleared_00;
// 查看索引表(
hive> select * from index_table_data_cleared_00;
// 加载索引数据
alter index index_data_cleared_00_exe_time on data_cleared_00 rebuild;
[root@master ~]# hadoop hdfs -text master.hadoop:9000/user/hive/warehouse/talentdata.db/data_cleared_t1_bak/part-00000-782f3236-3950-4b12-ab5a-8a964d6e1ad9-c000

三、常用配置:

1、hive.cli.print.header = true
2、hive.cli.print.current.db = true

相关文章

  • hive基本操作笔记

    一、几种操作方式: 1、文件内容: [root@master tmp]# vi hive_citys.sql1 s...

  • Hive编程指南笔记整理

    hive编程指南阅读笔记 1.基础操作 1.1.启动hive HIVE_HOME$ bin/hive 1.2.1....

  • HIVE

    基本操作 hive进入hive模式 exit; 退出hive模式 展示正则匹配表名hive> use ad_s...

  • Hive之同比环比的计算

    Hive系列文章 Hive表的基本操作[http://www.ikeguang.com/?p=1657] Hive...

  • Hive sql常见操作

    基本sql操作 hive表操作 分区操作 Hive内置函数 (1)数学函数 常用的数学函数都有:round、flo...

  • Hive 基本操作

    准备工作 1.检查各项服务是否已正常启动 [x] hdfs启动【start-dfs.sh】 [x] yarn启动【...

  • Hive 基本操作

    数据库基本操作 ( 和MySQL脚本相似 ): 创建删除库操作 创建删除表操作 hive 特点 Hive不支持修改...

  • Hive基本操作

    在所有操作前先启动hdfs、yarn、historyserver。 hive操作 启动hivebin/hive 创...

  • Hive基本操作

    参考:hive 表的常用操作Hive基本操作 1 Thrift Server Thrift 支持多种语言之间的RP...

  • Hive基本操作

    1.使用SQL文件创建一张表: hive -f create_table 2.将外部数据加载到一张表里面: LOA...

网友评论

    本文标题:hive基本操作笔记

    本文链接:https://www.haomeiwen.com/subject/splkphtx.html