HIVE基本操作

2021-09-01 00:01:10 字數 909 閱讀 5216

hive操作

一、建立分割槽

乙個表可以有多個分割槽,為避免過多的小檔案,建議只能對離散字段進行分割槽

create table if not exists stocks(

ymd date,

price_open float,

price_high float,

price_low float,

price_close float,

volume int,

price_adj_close float

)partitioned by(exchanger string,symbol string)

row format delimited fields terminated by』,』;

二、insert 的使用

insert into table1 partion(partion1)select * from table2;

如果是insert overwrite 則是table2覆蓋掉table1的資料。

三、建立外部表

create external table if not exists stocks_external (

ymd date,

price_open float,

price_high float,

price_low float,

price_close float,

volume int,

price_adj_close float

)partitioned by (exchanger string, symbol string)

row format delimited fields terminated by 『,』

location 『/user/bigdata/stocks』;

hive基本操作

1.顯示所有資料庫 show databases 2.使用某個資料庫 use xx xx表示某個資料庫名 3.顯示某資料庫下的所有表 show tables 4.檢視表結構 顯示各欄位 desc 表名 5.資料匯出到本地 在hive中操作 insert overwrite local directo...

hive 基本操作

檢視表的詳細資訊 desc 表名 desc formatted 表名 建立外部表 create external table emp ext empno int,ename string,job string,mgr int,hiredate string,sal double,comm doubl...

Hive基本操作

3 hive中的表 4 分割槽 partition 5 靜態分割槽和動態分割槽 6 分桶 bucket hive的資料都是儲存在hdfs上的,預設有乙個根目錄,在hive site.xml中,由引數hive.metastore.warehouse.dir指定。預設值為 user hive wareh...