Content

Hive导入csv文件示例(hive导入excel数据)满满干货

文章摘要

这篇文章描述了在数据库中进行数据格式转换的操作。首先,文章创建了一个名为`csv2`的表,并从本地CSV文件`/data/csv2.csv`中导入数据。接着,文章创建了一个名为`csv3`的新表,使用Parquet格式存储数据,并通过`INSERT OVERWRITE`语句将`csv2`表中的数据插入到`csv3`表中。文章的重点在于展示如何通过不同数据格式的转换来优化数据存储和查询性能。

drop table csv2; create table if not exists csv2 ( uid int, uname string, age int ) row format serde ‘org.apache.hadoop.hive.serde2.OpenCSVSerde’ stored as textfile; — 先导入csv文件到表格csv2,保存格式是textfile load data local inpath ‘/data/csv2.csv’ into table csv2; drop table csv3; — 创建csv3,保存格式parquet create table if not exists csv3 ( uid int, uname string, age int ) row format delimited fields terminated by ‘,’ stored as parquet; — 提取csv2的数据插入到csv3 insert overwrite table csv3 select * from csv2;