詹学伟
詹学伟
Published on 2024-04-21 / 14 Visits
0
0

hive建表语句

语法

CREATE TABLE [IF NOT EXISTS] [db_name.]table_name
(col_name data_type [COMMENT col_comment],...) [COMMENT table comment] 
[ROW FORMAT DELIMITED ...]

举例数据

2	马可波罗	5584	2003	623	44	remotely	archer
3	鲁班七号	5989	1756	400	323	remotely	archer
4	李元芳	5725	1770	396	340	remotely	archer
5	孙尚香	6014	1756	411	346	remotely	archer
6	黄忠	5898	1784	403	319	remotely	archer
7	狄仁杰	5710	1770	376	338	remotely	archer
8	虞姬	5669	1770	407	329	remotely	archer	assassin

sql操作

use test;
create table t_shooter
(
    id           int comment "ID编号",
    name         string comment "英雄名称",
    hp_max       int comment "最大生命",
    mp_max       int comment "最大法力",
    attack_max   int comment "最高物攻",
    defense_max  int comment "最大物防",
    attack_range string comment "攻击范围",
    role_main    string comment "由要定位",
    role_assist  string comment "次要定位"
)
row format delimited
fields terminated by "\t";

表字段coomment中文乱码问题:(在mysql中执行)

grant all privileges on *.* to 'APP'@'%' identified by 'root' with grant OPTION;
use hive3;
SHOW TABLES;
alter table hive3.COLUMNS_V2 modify column COMMENT varchar(256)character set utf8;

alter table hive3.TABLE_PARAMS modify column PARAM_VALUE varchar(4000)character set utf8;

alter table hive3.PARTITION_PARAMS modify column PARAM_VALUE varchar(4000)character set utf8;

alter table hive3.PARTITION_KEYS modify column PKEY_COMMENT varchar(4000)character set utf8;

alter table hive3.INDEX_PARAMS modify column PARAM_VALUE varchar(4000)character set utf8;


Comment