Hive第一天

这篇博客详细介绍了在Hive中创建和操作不同存储格式(TEXTFILE, RCFile, ORC, Parquet)的表的过程,以及数据的加载与压缩效果。还涉及到Hive的JDBC连接设置,数据库和表的创建、删除,以及数据分区等基本语法。通过实例展示了数据写入后的大小变化,突显了不同存储格式在压缩效率上的差异。" 111632229,10296626,腾讯开源GAME AI SDK:自动化测试吃鸡、MOBA类游戏,"['自动化测试', '游戏开发', '图像识别', 'AI算法', 'SDK开发']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

测试几种存储格式:

1. mkdir /usr/local/soft/hive-3.1.2/data/

2. 上传数据至data目录中

3.创建TEXTFILE学生信息表
create table students(

  id bigint comment '学生id',

  name string comment '学生姓名',

  age int comment '学生年龄',

  gender string comment '学生性别',

  clazz string comment '学生班级'

) comment '学生信息表' 

ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS TEXTFILE;

4.上传数据至HDFS
dfs -put /usr/local/soft/hive-3.1.2/data/ /user/hive/warehouse/filetest.db/students

5.通过查看HDFS路径可以看到数据大小没有发生变化 大小为37M

6.创建RCFile格式的学生信息表
create table students_rcFile(
  id bigint comment '学生id',
  name string comment '学生姓名',
  age int comment '学生年龄',
  gender string comment '学生性别',
  clazz string comment '学生班级'
) comment '学生信息表' 
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS RCFile;

7.插入数据:
insert into table students_rcFile select * from students;

8.通过查看HDFS路径可以看到数据经过压缩大小为26.44 M

9.创建ORCFile格式的学生信息表
create table students_orc(
  id bigint comment '学生id',
  name string comment '学生姓名',
  age int comment '学生年龄',
  gender string comment '学生性别',
  clazz string comment '学生班级'
) comment '学生信息表' 
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS ORC;

10.插入数据:
insert into table students_orc select * from students;

11.通过查看HDFS路径可以看到数据经过压缩大小为 220.38 KB,同时插入数据时与RCFile格式时间相差不大


12.创建Parquet格式的学生信息表
create table students_parquet(
  id bigint comment '学生id',
  name string comment '学生姓名',
  age int comment '学生年龄',
  gender string comment '学生性别',
  clazz string comment '学生班级'
) comment '学生信息表' 
ROW FORMAT DELIMITED FIELDS TERMIN

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值