Hive常用命令

2022-08-30 18:48:17 字數 1071 閱讀 6064

1#建表(預設是內部表)

create table test_hive(id bigint,account string,expense double,time string) row format delimited fields terminated by '\t';

#建分割槽表(有大量資料增加的需要建分割槽表)

create table test_part(id bigint,account string,expense double,time string)

partitioned by (logdate string)

row format delimited fields terminated by '\t';

#建外部表

create external table test_ext(id bigint,account string,expense double,time string) row format delimited fields terminated by '\t' location '/test_ext';

2#載入資料到表

#把本地資料裝載到資料表,也就是在metastore上建立資訊

loda data local inpath '/root/a.txt' into table test_hive;

#把hdfs上的資料裝載到資料表

loda data inpath '/target.txt' into table test_hive;

3#hive的shell下可以執行hdfs和linux命令

hadoop中的 hadoop fs -ls / 在hive下這樣執行:dfs -ls /

source my.sql(hive下執行sql檔案)

hive -e "hiveql"(不進入hive的互動模式,直接執行命令)

4#其他一些常用命令類似於sql

show tables;(展示所有表)

desc tablename;(描述表結構)

show create table tablename(檢視建立表資訊)

show partitions tablename;(檢視表的分割槽)

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 判...