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