1、创建表的时候,comment说明字段包含中文,表成功创建成功之后,中文说明显示乱
create table student_score(
stu_id string comment '学生id',
stu_name string,
courses string,
scores string
);
2、加载中文数据到表中,结果出现乱码
hive> insert into student_score values
> ("1001", "张三","语文,数学,英语,历史,地理", "88,87,94,86,84"),
> ("1002", "李四", "语文,数学,英语,历史,地理", "78,89,75,79,68"),
> ("1003", "王五", "语文,数学,英语,历史,地理", "98,97,91,93,92"),
> ("1004", "朱六", "语文,数学,英语,历史,地理", "66,63,64,67,68");
1、 进入Mysql并切到Hive库下:
use hive;
2、执行以下 5 条 SQL 语句
(1)修改表字段注解和表注解
alter table COLUMNS_V2 modify column COMMENT varchar(256) character set utf8;
alter table TABLE_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8;
(2)修改分区字段注解
alter table PARTITION_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8;
alter table PARTITION_KEYS modify column PKEY_COMMENT varchar(4000) character set utf8;
(3)修改索引注解
alter table INDEX_PARAMS modify column PARAM_VALUE varchar(4000) character set utf8;
3、修改 metastore 的连接 URL
[root@master conf]# vim hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8
<description>JDBC connect string for a JDBC metastore</description>
</property>
drop table student_score;
create table student_score(
stu_id string comment '学号',
stu_name string comment '姓名',
courses string comment '各个科目',
scores string comment '各个分数'
) comment '学生成绩表';
但但中文数据导入乱码问题还没有解决