TINYINT(取值范围:-128 – 127)
SMALLINT(取值范围:-32,768 to 32,767)
INT/INTEGER(取值范围: -2,147,483,648 to 2,147,483,647)
BIGINT(取值范围: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
使用举例
数据类型 后缀 举例
TINYINT Y 100Y
SMALLINT S 100S
BIGINT L 100L
Float(4byte位双精度小数,精确到8位小数)
Double(8byte位双精度小数, 精确到小数点后16位)
DECIMAL(自定义小数,长度自定义)
主要有两个:
TIMESTAMP: 时间戳,类似2018-09-09 11:59:59
DATE:日期,类似2018-09-09
其他一个时间间隔:(INTERVAL)如感兴趣,可以参考官网:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-Intervals
CHAR (最长指定255位)
VARCHAR(指定的长度范围0–65535)
STRING (单引号” 或者双引号括起来的内容,注意转义字符)
CREATE TABLE foo (bar CHAR(10))
CREATE TABLE foo1 (bar VARCHAR(1000))
BOOLEAN (类似java boolean)
BINARY (2进制格式)
arrays: ARRAY (Note: negative values and non-constant expressions are allowed as of Hive 0.14.)
maps: MAP
用法举例:
create table if not exists employee(
name string,
salary float,
subordinates array<string>,
decutions map<string, float>,
structstring, state:string, zip:int>
)
分别表示名字,薪水,下属员工, 薪水扣除事项(公积金、医疗保险),地址(街道,城市,州,)
参考(hive 官网:数据类型: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-char )