Hive_Hive 의 데이터 모델외부 테이블

Hive 데이터 모델 의 외부 표
외부 테이블 (External Table) - HDFS 에 존재 하 는 데 이 터 를 가리 키 며, Partition - 내부 테이블 과 메타 데이터 의 조직 은 같 지만, 실제 데이터 의 저장 은 비교적 큰 차이 가 있 습 니 다.외부 사촌 조 카 는 데 이 터 를 불 러 오고 표를 만 드 는 과정 이 있 습 니 다. 데이터 창고 디 렉 터 리 로 이동 하지 않 고 외부 데이터 와 링크 만 만 만 듭 니 다.외부 테이블 을 삭제 할 때 이 링크 만 삭제 합 니 다.
1、             txt  ,  HDFS /input    。
2、 hive                external_student,location   HDFS /input   。 external_student     /input     。
3、     。  /input                 。
4/input        。
5、     。             。
6/input  。
7、     。            。

 
예 를 들 면 다음 과 같다.
(1) 준비 데이터:
student1.txt
1,Tom,M,60,80,96
2,Mary,F,11,22,33

student2.txt
3,Jerry,M,90,11,23

student3.txt
4,Rose,M,78,77,76
5,Mike,F,99,98,98

 
  HDFS         。
# hdfs dfs -ls /

  input  。
# hdfs dfs -mkdir /input

 
     HDFS    
hdfs dfs -put localFileName hdfsFileDir
# hdfs dfs -put student1.txt /input
# hdfs dfs -put student2.txt /input
# hdfs dfs -put student3.txt /input

(2) 외부 테이블 만 들 기
create table external_student
(sid int, sname string, gender string, language int, math int, english int)
row format delimited fields terminated by ',' 
location '/input';

(3) 외부 테이블 조회
select * from external_student;

(4) HDFS 의 student 1. txt 삭제
# hdfs dfs -rm /input/student1.txt

(5) 외부 테이블 조회
select * from external_student;

(6) student 1. txt 를 HDFS input 디 렉 터 리 에 다시 넣 기
# hdfs dfs -put student1.txt /input

(7) 외부 테이블 조회
select * from external_student;

 
다음으로 전송:https://www.cnblogs.com/liupuLearning/p/6323004.html

좋은 웹페이지 즐겨찾기