
点击上方蓝色文字关注我们吧

“ 本文记录hive的数据几种导入及导出方法”
一、hive数据导入方法
1、加载本地或HDFS上的数据文件
LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)]
local:有该关键字表示本地数据文件,没有表示hdfs路径上的数据文件
overwrite:有该关键字表示覆盖,没有表示追加

2、
create table if not exists tb_name as select * from tb_name2;

3、
create table if not exists tb_name like tb_name2;insert into table tb_name select * from tb_name2;

4、创建表时加载HDFS上的数据文件
create table if not exists tb_name(id int,name string)row format delimited fields terminated by '\t'location 'HDFS_PAHT';

5、import
import table tb_name [partition(day='01')] from 'hdfs_path'
注:其中导入数据的路径必须是export导出的路径,否则报Invalid path


INSERT OVERWRITE [LOCAL] DIRECTORY directory1[ROW FORMAT row_format] [STORED AS file_format] (Note: Only available starting with Hive 0.11.0)SELECT ... FROM ...

hive -e 'select * from default.emp' > /home/hive_emp.txt

EXPORT TABLE tablename [PARTITION (part_column="value"[, ...])]TO 'export_target_path'




文章转载自大数据学习记录,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




