欢迎投稿

今日深度:

Hive常用命令,

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

 

www.htsjk.Com true http://www.htsjk.com/hive/27480.html NewsArticle Hive常用命令, 1#建表(默认是内部表) create table test_hive(id bigint,account string,expense double,time string) row format delimited fields terminated by '\t'; #建分区表(有大量数据增加的需要建分区表) c...
相关文章
    暂无相关文章
评论暂时关闭