① 在hive中执行HDFS命令:创建/data目录
hive命令终端输入:
hive> dfs -mkdir -p /data;
或者在linux命令终端输入:
hdfs dfs -mkdir -p /data;
② 在hive中执行HDFS命令:上传/emp.txt至HDFS的data目录下,并命名为emp_out
Hive命令终端输入:
hive> dfs -put /emp.txt /DATA/emp_out;
或者Linux命令终端输入:
hdfs dfs -put /emp.txt /DATA/emp_out;
③ 创建外部表:emp_out
create external table emp_out(
empno int,
ename string,
job string,
mgr int,
hiredate string,
sal double,
comm double,
deptno int)
row format delimited fields terminated by ','
location '/data';
④ 验证:
select * from emp_out;
查询结果如下:
文章来源:https://www.toymoban.com/news/detail-628611.html
注意: emp.txt文件内容为:文章来源地址https://www.toymoban.com/news/detail-628611.html
7369,SMITH,CLERK,7902,1980-12-17,800.00,,20
7499,ALLEN,SALESMAN,7698,1981-2-20,1600.00,300.00,30
7521,WARD,SALESMAN,7698,1981-2-22,1250.00,500.00,30
7566,JONES,MANAGER,7839,1981-4-2,2975.00,,20
7654,MARTIN,SALESMAN,7698,1981-9-28,1250.00,1400.00,30
7698,BLAKE,MANAGER,7839,1981-5-1,2850.00,,30
7782,CLARK,MANAGER,7839,1981-6-9,2450.00,,10
7839,KING,PRESIDENT,,1981-11-17,5000.00,,10
7844,TURNER,SALESMAN,7698,1981-9-8,1500.00,0.00,30
7900,JAMES,CLERK,7698,1981-12-3,950.00,,30
7902,FORD,ANALYST,7566,1981-12-3,3000.00,,20
7934,MILLER,CLERK,7782,1982-1-23,1300.00,,10
到了这里,关于Hive创建外部表详细步骤的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!