hive 基本操作

2021-08-17 21:18:00 字數 1299 閱讀 1505

檢視表的詳細資訊

desc 表名;

desc formatted 表名;

建立外部表:

create

external

table emp_ext(

empno int,

ename string,

job string,

mgr int,

hiredate string,

sal double,

comm double,

deptno int

)row format delimited fields terminated by

'\t';

載入資料

load data local inpath '/opt/hivedata/dept.txt'

into

table emp_ext;

管理表和外部表的區別

一般都使用外部表,為了保證資料的安全性。

-e + 『sql語句』

栗子:bin/hive -e 'select * from mydb.stu' 增刪改查

-f + hql檔案

在hive目錄下,建立乙個目錄test,在test中建立檔案testf.hql

把select * from mydb.stu寫進testf.hql

栗子:bin/hive -f test/testf.hql

情況:sql語句比較複雜,需要週期性執行的

-s 靜默模式

栗子:bin/hive -s -f test/testf.hql

-i 返回資料之後,直接進入客戶端 初始化的操作

栗子:bin/hive -i  test/testf.hql 

上面的栗子都是在hive目錄下操作的

source + hql檔案

栗子:source test/testf.hql;

20171014

20171015

20171016 按照每個小時的

2017101610.log

2017101611.log

2017101612.log

2017101613.log

2017101613...

分割槽表語法

動態分割槽(二級分割槽)

hive基本操作

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

HIVE基本操作

hive操作 一 建立分割槽 乙個表可以有多個分割槽,為避免過多的小檔案,建議只能對離散字段進行分割槽 create table if not exists stocks ymd date,price open float,price high float,price low float,price...

Hive基本操作

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