Hive的資料型別 和建表模型

2021-10-10 23:11:52 字數 1319 閱讀 9630

資料型別為常用

tinyint 1byte有符號整數 20

smallint 2byte有符號整數 20

int ** 有符號整數 20

bigint8byte有符號整數 20

boolean 布林型別,true或者false true false

float 單精度浮點數 3.14159

double ** 雙精度浮點數 3.14159

string ** 字元系列。可以指定字符集。可以使用單引號或者雙引號。 『now is the time』 「for all good men」

timestamp **

binary

還有一些其他資料型別比如arra。。。

建表表示可以省略的部分:

//此行指出所建表為內部或者外部表,還有表名,不存在才會建立

create [external 外部表] table [if not exists 是否存在] table_name

//此行指出:列名 其資料型別 【注釋】 ,…表示可以寫多個

[(col_name data_type [comment col_comment], …)]

//表注釋,不支援漢字

[comment table_comment]

//分割槽 通過 字段 資料型別 【注釋】

[partitioned by (col_name data_type [comment col_comment], …)]

//分桶 通過 字段 。。。

[clustered by (col_name, col_name, …)

//以欄位排序 公升序|降序

[sorted by (col_name [asc|desc], …)] into num_buckets buckets]

//指定行資料以什麼做的分隔符

[row format row_format] row format delimited fields terminated by

//指定資料儲存的資料格式

[stored as file_format]

//指出表中資料在hdfs中的位置

[location hdfs_path]

例如:create external table tb_log2( --external修飾的為 外部表

id int ,

name string

)row format delimited fields terminated by 「,」 //以逗號為分隔符

location 『/data/log/』 ; //指出表中資料在hdfs中的位置

Hive 資料型別和建表語法

tinyint 1byte有符號整數 20 smallint 2byte有符號整數 20 int 有符號整數 20 bigint 8byte有符號整數 20 boolean 布林型別,true或者false true false float 單精度浮點數 3.14159 double 雙精度浮點數 ...

MySQL建表過程 資料型別

a.主要學習列型別的儲存範圍與佔據的位元組關係 b.儲存同樣的資料不同列型別所佔據的空間和效率是不一樣的 c.乙個位元組八個位 d.參考 1 數值型 b.整形 tinyint 佔1個位元組 128 127 or 0 255 smallint 2個位元組 mediuint 3個位元組 int 4個位元...

Hive 建表 插入資料 插入復合型別

新建hive表 create table test a timestamp b struct 下面可選 row format delimited fields terminated by t stored as parquet 檢視建好的表的結構 hive show create table tes...