hive 通过csv文件创建表

1.建表

create table mytable(userid string,name string)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar"     = "'",
"escapeChar"    = "\\"
)
STORED AS TEXTFILE;

2.载入数据

load data local inpath '/home/hadoop/temp/mytable.csv' overwrite into table mytable;

3.若出现hive载入csv中文乱码,则可直接编辑文件格式

vim mytable.csv

:set fileencoding=utf8

:set fileencodings=utf8

保存即可


你可能感兴趣的:(HIVE,hive)