Hive常用命令


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;(查看表的分區)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM