Hive 常用語句

2021-10-08 05:11:24 字數 1159 閱讀 4286

1、建立外部表(最後一行指定位置)

2、 覆蓋插入除某個欄位外的其他字段 (如 ms 字段)

這種適合於直接分割槽表的資料插入到新錶,但是不需要舊表的分割槽字段。

set hive.support.quoted.identifiers=none;

insert overwrite table db.tb01 partition(ms='$yesterday') select \`(ms)?+.+\` from rawdata.tb01 where ms='$yesterday'  ;

hive -e 執行需要轉義 \`(ms)?+.+\`

hive -f 執行不需要轉義

3、beeline 執行hive的sql

beeline -u "jdbc:hive2:"  -n username -p password -e "show databases;"

-d ---使用乙個驅動類:beeline -d driver_class    

-e ---使用乙個查詢語句:beeline -e "query_string"    

-f ---載入乙個檔案:beeline -f filepath  多個檔案用-e file1 -e file2  

-n ---載入乙個使用者名稱:beeline -n valid_user    

-p ---載入乙個密碼:beeline -p valid_password    

-u ---載入乙個jdbc連線字串:beeline -u db_url 

4、建立普通的內部表(以製表符分隔)

create table `temp.tb01`(

`uid` string , 

`os` string , 

)row format delimited 

fields terminated by '\t';

建立完成可以

show create table `temp.tb01` ;

5、修復分割槽

msck repair table db.tablename; 

HIVE常用語句

1.給表新增字段 alter table 表名 add columns 欄位名 資料型別 alter table bi dpa.tdpa utm src td add columns utm src cate id s integer 2.檢視表結構 一般情況下,只需要desc tablename ...

hive常用語句

1.匯入有分割槽的資料 oracle語句 select from xx partition fmlg part where conditions 2.增量匯入關係型資料庫orcle的where語句表示式 select from xx where d update to date 20170423 y...

Hive常用語句記錄

alter table rename to 表新增字段 alter table tablename add columns field type 分割槽新增字段 alter table tablename partition yyy add columns field type alter tabl...