Hive常用命令

2022-07-12 22:42:20 字數 1028 閱讀 2897

1、建立表:

create table if not exists employee (eid int,name string,salary string,destination string)

comment 'employee details'

row format delimited

fields terminated by '\t'

lines terminated by '\n'

stored as textfile;

如果增加分割槽必須在建立表的時候就建立分割槽,不然就會報錯,建立分割槽的命令》partition by 『根據哪個字段分割槽』,

create table employee (id int, name string, dept string)

partitioned by (year int)

row format delimited

fields terminated by '\t'

lines terminated by '\n'

stored as textfile;

stored as textfile檔案格式,檔案格式在hive中有三種: textfile、sequencefile(序列化檔案,學hadoop的都會知道啦)、rcfile。

2、新增資料到表中

load data inpath '/data/sample.txt' //hdfs路徑

load data local inpath '/home/chan/sample.txt' //本地路徑

load data:載入資料; local:本地資料 inpath:檔案的位址

附加:overwrite:覆蓋表中的資料 加overwrite是重寫表的資料,不加是追加資料

插入表資料:insert into employee(eid,name) values (1208,'jack');

hive只支援插入不支援修改和刪除

3、重新命名表名字

alter table employee rename to emp;

hive常用命令

進入hive目錄後執行hive命令進入命令模式 建立新錶 hive create table t hive a int,b int,c int row format delimited fields terminated by t 匯入資料t hive.txt到t hive表 hive load d...

hive常用命令

建立新錶 hive create table t hive a int,b int,c int row format delimited fields terminated by t 匯入資料t hive.txt到t hive表 hive load data local inpath home co...

Hive常用命令

檢視hdfs路徑 show create table table name 建表 create table tbname var1 char type1,var2 char type2 載入資料到表 刪除表 drop table tbname if expr1,expr2,expr3 expr1 判...