数据导出的分类:
-
从hive表中导出本地文件系统中(目录、文件)
-
从hive表中导出hdfs文件系统中
-
hive表中导出到其它hive表中
1)导出数据到本地目录
insert overwrite local directory '/root/out/00' select * from t_user;
这个00不是文件名,而是文件夹的名字,没有可以自动创建

2)导出到hdfs的目录下
insert overwrite directory '/root/out/00' select * from t_user;

假如你导出的数据想要一个分隔符,比如 逗号
insert overwrite directory '/root/out/00'
row format delimited fields terminated by ','
select * from t_user;

3)直接将结果导出到本地文件中
hive -e "sql语句" 不需要进入hive,直接执行hive的语句
hive -e "select * from yhdb.t_user" >> /root/out/a.txt
hive -e "use yhdb;select * from t_user" >> /root/out/a.txt

制表符就是 Tab 键,Tab 键就是 \t