zoukankan      html  css  js  c++  java
  • Hive学习之路(三)Hive处理中文乱码

    Hive注释中文乱码

    创建表的时候,comment说明字段包含中文,表成功创建之后,中文说明显示乱码

    create external table movie(
    userID int comment '用户ID',
    movieID int comment '电影ID',
    rating int comment '电影评分',
    timestamped bigint comment '评分时间戳',
    movieName string comment '电影名字', 
    movieType string comment '电影类型', 
    sex string comment '性别', 
    age int comment '年龄', 
    occupation string comment '职业', 
    zipcode string comment '邮政编码'
    ) comment '影评三表合一' 
    row format delimited fields terminated by ","
    location '/hive/movie';
    

    1.进入数据库Metastore中执行以下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';
    

    修改metastore连接的URL

    image-20190820225553386

    <configuration>
            <property>
                    <name>javax.jdo.option.ConnectionURL</name>
                    <value>jdbc:mysql://localhost:3306/hivedb?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=UTF-8</value>
            </property>
            <property>
                    <name>javax.jdo.option.ConnectionDriverName</name>
                    <value>com.mysql.jdbc.Driver</value>
            </property>
            <property>
                    <name>javax.jdo.option.ConnectionUserName</name>
                    <value>root</value>
            </property>
            <property>
                    <name>javax.jdo.option.ConnectionPassword</name>
                    <value>Root123456+</value>
            </property>
    </configuration>
    

    验证

    drop table movie;
    

    image-20190820225328549

  • 相关阅读:
    数论笔记
    哈哈哈
    闭关修炼屯题中,期末考完A
    acm几何
    POJ
    Educational Codeforces Round 42 (Rated for Div. 2) D.Merge Equals (优先队列)
    Educational Codeforces Round 42 (Rated for Div. 2) C. Make a Square (dfs)
    牛客网 VVQ 与线段 (优先队列或线段树或RMQ)
    Educational Codeforces Round 41 (Rated for Div. 2) C.Chessboard (DP)
    Educational Codeforces Round 41 (Rated for Div. 2)D. Pair Of Lines
  • 原文地址:https://www.cnblogs.com/shine-rainbow/p/11386187.html
Copyright © 2011-2022 走看看