Insert导出
查询结果导出到本地:insert overwrite local directory '/home/lzx/tmpfile/student5' select * from student5;
student5是分区表,这里必须使用 overwrite
将查询的结果格式化导出到本地:insert overwrite local directory '/home/lzx/tmpfile/student5_3' row format delimited fields terminated by '\t' select * from student5;
将查询结果导出到HDFS上(没有local):insert overwrite directory '/tmpfile/student5' row format delimited fields terminated by '\t' select * from student5;
Hadoop 命令导出到本地
其实就是使用hadoop命令吧hdfs的文本拷贝下来。
get命令:hadoop fs -get /tmpfile/student5/000000_0 /home/lzx/tmpfile/student5.txt
Hive Shell 命令导出
hive 支持 -f / -e 分别执行脚本或者语句
执行语句:./hive -e 'select * from student5;' > /home/lzx/tmpfile/student5_1.txt
Export 导出到HDFS上
执行hive语句:export table student5 to '/tmpfile/student5_export_new';
其实就是拷贝数据文件,只不过是带有元数据的。
清除表数据
和传统数据库是一样的使用truncate table tb_name;