Hive建表語句解釋

2021-10-08 04:27:46 字數 740 閱讀 2365

drop table if exists 'tablename'

;create external table 'tablename'

('id' string comment 'id'

,'name' string comment '名字'

,'price' double comment '**',)

comment '表名'

partitioned by (ds string)

stored as parquet

location '/warehouse/自定義儲存位置/test/'

tblproperties (

"parquet.compression"="lzo"

);

語句

含義create external table

建立外部表

comment

表或字段註解

partitioned by (ds string)

按日期分割槽 例如 『2020-07-16』

stored as parquet

以parquet格式儲存

location

指定儲存路徑,不指定為預設路徑 /usr/hive/warehouse/

tblproperties

hive內建了一部分屬性

lzohdfs的壓縮方式

關於parquet列式儲存格式,有乙個講的很詳細的文章

hive建表語句

1 只保留表的結構 create table table1 as select from table2 where 2 3 2 保留結構與資料 create table table1 as select from table 2 3 重新命名 create table table1 column1 ...

hive中建表語句

hive中一共有以下幾種建表方式 create table person id int,name string,hobbies array,address map row format delimited fields terminated by collection items terminate...

批量生成hive建表語句

這裡以shell為例 bin bash db dim echo 匯出資料庫所有的表結構 hive e use db show tables root migration db tables.txt echo 迴圈遍歷表名 cat root migration db tables.txt while ...