关于数据库:hive建表并导入csv文件数据

41次阅读

共计 690 个字符,预计需要花费 2 分钟才能阅读完成。

先是在的 hive 命令行建的表,胜利导入了,然而 impala 客户端查不到,而后刷新了元数据(invalidate metadata 表名)
impala 报错不反对 org.apache.hadoop.hive.serde2.OpenCSVSerde
而后就选了第二种办法(留神分隔符)

 一、建表
1.
create table if not exists test.product_browsing (
    user_id STRING,
    phone STRING, 
    goods_id STRING, 
    goods_name STRING,
    view_date STRING,
    view_time STRING

) row format serde
'org.apache.hadoop.hive.serde2.OpenCSVSerde'
with
SERDEPROPERTIES
("separatorChar"=",","quotechar"="\"")
STORED AS TEXTFILE;

2.
create table if not exists Impala.test.product_browsing (
    user_id STRING,
    phone STRING, 
    goods_id STRING, 
    goods_name STRING,
    view_date STRING,
    view_time STRING

) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE;

二、加载数据命令
load data local inpath '/home/data.csv' overwrite into table test.product_browsing;

正文完
 0