查询语句中创建表并加载数据:create table score2 as select * from score1;
在创建表是通过location指定加载数据的路径:create external table score6 (s_id string,c_id string,s_score int) row format delimited fields terminated by ‘,’ location ‘/myscore’;
export导出与import 导入 hive表数据(内部表操作):
create table techer2 like techer; –依据已有表结构创建表
export table techer to ‘/export/techer’;
import table techer2 from ‘/export/techer’;
hive表中数据导出
insert导出
将查询的结果导出到本地:insert overwrite local directory ‘/export/servers/exporthive’ select * from score;
将查询的结果格式化导出到本地:insert overwrite local directory ‘/export/servers/exporthive’ row format delimited fields terminated by ‘\t’ collection items terminated by ‘#’ select * from student;
将查询的结果导出到HDFS上(没有local):insert overwrite directory ‘/export/servers/exporthive’ row format delimited fields terminated by ‘\t’ collection items terminated by ‘#’ select * from score;