Hive 数据类型 | Java 数据类型 | 长度 |
---|---|---|
TINYINT | byte | 1 byte 有符号整数 |
SMALINT | short | 2 byte 有符号整数 |
INT | int | 4 byte 有符号整数 |
BIGINT | long | 8 byte 有符号整数 |
FLOAT | float | 单精度浮点数 |
DOUBLE | double | 双精度浮点数 |
STRING | string | 字符系列, 可以使用单引号或双引号 |
TIMESTAMP | 时间类型 | |
BINARY | 字节数组 |
Hive 数据类型 | 描述 | 语法示例 |
---|---|---|
STRUCT | 类似于C语言的struct | |
MAP | map | |
ARRAY | 数组 |
// 原始数据: complicated.txt
zhangsan,lisi_wangwu,xiao zhang:20_zhangfei:22,zhong guan cun_beijing
// 创建表语句
create table studentInfo(
name string,
friends array<string>,
children map<string, int>,
address struct<street:string, city:string>
)
row format delimited
fields terminated by ','
collection items terminated by '_'
map keys terminated by ':'
lines terminated by '\n';
// 查询语句
select friends[1],children['wangwu'],address.street from studentInfo;
create database if not exists db_hive;
show databases;
show databases like ‘条件‘;
desc database db_hive;
desc database extended db_hive;
alter database db_hive set dbproperties(‘CTtime‘=‘2019-06-21‘);
drop database db_hive;
drop database db_hive cascade;
原文:https://www.cnblogs.com/linkworld/p/11029151.html