다음은 하이브로 데이터를 가져 오는 데 일반적으로 사용되는 몇 가지 방법을 소개합니다.
1. 하이브에 로컬 파일로드
load data local inpath '/data/hive/student_info.txt' into table default.student_info
2. hdfs 파일을 하이브에로드
load data inpath '/data/hive/student_info.txt' into table default.student_info
3. 데이터를로드하여 테이블의 기존 데이터를 덮어 씁니다.
load data inpath '/data/hive/student_info.txt' overwrite into table default.student_info
4. 테이블 생성시 Insert를 통해 데이터 삽입
create table default.student_info_c1 like student_info;
insert into table default.student_info_c1 select * from default.student_info;
5. 테이블 생성시 위치를 통한로드
create table user_info_t1(
id int
,name string
,hobby array<string>
,add map<String,string>
)
STORED AS TEXTFILE
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':'
LOCATION '/hive/data/ ';
6. 가져 오기 방법
import table student_info partition (country="china") from "/data/hive/import/"