Hive导入数据的6种方式

下面介绍几种常用的导入数据到hive的方式 

   1. 加载本地文件到hive

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

   2. 加载hdfs文件到hive中

    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.  创建表的时候通过location 加载

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 方法

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

猜你喜欢

转载自blog.csdn.net/qq_32445015/article/details/102007474
今日推荐