6 ways to import data in Hive

The following introduces several commonly used methods of importing data to hive 

   1. Load local files to hive

     load data local inpath '/data/hive/student_info.txt' into table default.student_info 

   2. Load the hdfs file into hive

    load data inpath '/data/hive/student_info.txt' into table default.student_info

   3. Load data to overwrite the existing data in the table

    load data inpath '/data/hive/student_info.txt' overwrite into table default.student_info

   4. Insert data through insert when creating a table

create table default.student_info_c1 like student_info;
insert into table default.student_info_c1 select * from  default.student_info;

   5. Load through location when creating a table

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 method

    import table student_info partition (country="china") from "/data/hive/import/"

 

Guess you like

Origin blog.csdn.net/qq_32445015/article/details/102007474