hive常用命令
2016-03-24 17:37
309 查看
进入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 DATA LOCAL INPATH '/home/cos/demo/t_hive.txt' OVERWRITE INTO TABLE t_hive ;
#正则匹配表名
hive>show tables '*t*';
#增加一个字段
hive> ALTER TABLE t_hive ADD COLUMNS (new_col String);
#重命令表名
hive> ALTER TABLE t_hive RENAME TO t_hadoop;
#从HDFS加载数据
hive> LOAD DATA INPATH '/user/hive/warehouse/t_hive/t_hive.txt' OVERWRITE INTO TABLE t_hive2;
#从其他表导入数据
hive> INSERT OVERWRITE TABLE t_hive2 SELECT * FROM t_hive ;
#创建表并从其他表导入数据
hive> CREATE TABLE t_hive AS SELECT * FROM t_hive2 ;
#仅复制表结构不导数据
hive> CREATE TABLE t_hive3 LIKE t_hive;
#通过Hive导出到本地文件系统
hive> INSERT OVERWRITE LOCAL DIRECTORY '/tmp/t_hive' SELECT * FROM t_hive;
#Hive查询HiveQL
from ( select b,c as c2 from t_hive) t select t.b, t.c2 limit 2;
select b,c from t_hive limit 2;
#创建视图
hive> CREATE VIEW v_hive AS SELECT a,b FROM t_hive;
#删表
drop table if exists t_hft;
#创建分区表
DROP TABLE IF EXISTS t_hft;
CREATE TABLE t_hft(
SecurityID STRING,
tradeTime STRING,
PreClosePx DOUBLE
) PARTITIONED BY (tradeDate INT)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
#导入分区数据
hive> load data local inpath '/home/BlueBreeze/data/t_hft_1.csv' overwrite into table t_hft partition(tradeDate=20130627);
#查看分区表
hive> SHOW PARTITIONS t_hft;
#创建新表
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/cos/demo/t_hive.txt' OVERWRITE INTO TABLE t_hive ;
#正则匹配表名
hive>show tables '*t*';
#增加一个字段
hive> ALTER TABLE t_hive ADD COLUMNS (new_col String);
#重命令表名
hive> ALTER TABLE t_hive RENAME TO t_hadoop;
#从HDFS加载数据
hive> LOAD DATA INPATH '/user/hive/warehouse/t_hive/t_hive.txt' OVERWRITE INTO TABLE t_hive2;
#从其他表导入数据
hive> INSERT OVERWRITE TABLE t_hive2 SELECT * FROM t_hive ;
#创建表并从其他表导入数据
hive> CREATE TABLE t_hive AS SELECT * FROM t_hive2 ;
#仅复制表结构不导数据
hive> CREATE TABLE t_hive3 LIKE t_hive;
#通过Hive导出到本地文件系统
hive> INSERT OVERWRITE LOCAL DIRECTORY '/tmp/t_hive' SELECT * FROM t_hive;
#Hive查询HiveQL
from ( select b,c as c2 from t_hive) t select t.b, t.c2 limit 2;
select b,c from t_hive limit 2;
#创建视图
hive> CREATE VIEW v_hive AS SELECT a,b FROM t_hive;
#删表
drop table if exists t_hft;
#创建分区表
DROP TABLE IF EXISTS t_hft;
CREATE TABLE t_hft(
SecurityID STRING,
tradeTime STRING,
PreClosePx DOUBLE
) PARTITIONED BY (tradeDate INT)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
#导入分区数据
hive> load data local inpath '/home/BlueBreeze/data/t_hft_1.csv' overwrite into table t_hft partition(tradeDate=20130627);
#查看分区表
hive> SHOW PARTITIONS t_hft;
相关文章推荐
- FFmpeg一些学习资料
- 在Android studio中进行单元测试和ui测试
- 基于qt的五子棋 人人对战 人机对战 程序与程序对战
- 深入理解RunLoop
- Java基本知识之三(多线程)
- 红糖水与白糖水
- 【JAVA】修改项目包名
- Java——复选框:JCheckBox
- JS中几种常见的创建对象的方法
- 11.友盟相关
- Shellcoding for Linux and Windows Tutorial
- c#怎样连接MySQL数据库
- Android安装包各子包介绍
- 2
- ★ Linked List Cycle II -- LeetCode
- 2016苹果春季发布会 iPhone SE发布
- ORACLE之PACKAGE
- linux---进程相关的命令
- DHCP负载均衡 实验
- Oracle Database 11g For Windows7 旗舰版的安装