Hive Hive中表建立方式及其對比

2021-10-09 05:19:26 字數 1035 閱讀 4933

首先就是最常見的方式,通create table方式進行建立hive表

例如?

create [external] table [if not exists] tablename

(column columntype comment 'annotation',

column columntype comment 'annotation',

column columntype comment 'annotation',

...)

partitioned by (column columntype...)

stored as orc

row format delimited fields terminated by ','

location 'path';

這種方式的好處是可以清晰的定製hive表的字段、分割槽、注釋、儲存方式、資料分隔符、位置等等

對於 create as ,這種方式的語法如下?

craete table tablename as select * from targettablename;
這種方式建立表非常方便,可以快速從目標表中篩選所需要的字段以及資料,並且建立的表的結構和目標表基本一致,但是如果目標表是分割槽表,是不會將分割槽結構也複製的,如果查詢了分割槽字段,那麼分割槽欄位只會作為複製表的乙個普通字段,所以如果想要複製分割槽,那這種方式是不適合的,而且也不會複製目標表的注釋,這就是這種方式的缺點

對於 create like ,這種方式的語法如下?

craete table tablename as targettablename;
通過上面的語法可以看出,這種方式是不會複製目標表的資料的,只會複製目標表的結構

craete table 是最常用的創表方式,可以對錶進行清晰的定製

create as 創表可以快速的將一張表的資料查詢出來並儲存到新錶中

create like 創表可以快速的複製目標表的結構

Hive Hive引數配置方式

hive引數配置方式 語法結構 hive hiveconf x y i filename f filename e query string s hive引數大全 開發hive應用時,不可避免地需要設定hive的引數。設定hive的引數可以調優hql 的執行效率,或幫助定位問題。然而實踐中經常遇到的...

Hive Hive中表連線的優化,加快查詢速度

1 多表連線的執行順序和mapreduce job優化 select a.ymd a.price close b.price close c.price close from stocks a join stocks b on a.ymd b.ymd join stocks c on a.ymd c...

hive hive中建立表

一 建立表語句 create table if not exists mydb.employees name string comment employee name salary float subordinates arraydeductions mapaddress struct commen...