Hive常用命令总结
1.建表
#建表(默认是内部表) create table trade_detail(id bigint, account string, income double, expenses double, time string) row format delimited fields terminated by " "; #建分区表 #普通表和分区表区别:有大量数据增加的需要建分区表 create table td_part(id bigint, account string, income double, expenses double, time string) partitioned by (logdate string) row format delimited fields terminated by " "; #建外部表 create external table td_ext(id bigint, account string, income double, expenses double, time string) row format delimited fields terminated by " " location "/td_ext";
2.加载数据到表
#把本地数据装载到数据表,也就是在metastore上创建信息 load data local inpath "/root/a.txt" into table trade_detail; #把HDFS上的数据装载到数据表 load data inpath "/target.txt" into table trade_detail; #加载数据到分区表必须指明所属分区 load data local inpath "./book.txt" overwrite into table book partition (pubdate="2010-08-22");
在Hive shell下执行hadoop命令行: #比如:hadoop fs -ls /,在hive下可以这样执行: hive> dfs -ls /; 在Hive shell下执行linux系统命令: !cmd; 例如:!pwd;打印当前工作目录 在Hive shell下执行sql文件: hive> source my.sql; hive -S 以静默模式启动hive(不打印日志信息,纸打印结果); hive -e "HiveQL",不进入hive的交互模式,直接执行命令; 当然也可以结合静默模式一起使用:hive -S -e "HiveQL"
4.另外一些常用的命令其实就是SQL:
#描述表结构 desc tablename; #查看创建表信息 show create table tablename; #查看表的分区 show partitions tablename;
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: windows下配置ipfs
- 下一篇: IPFS 入门笔记