HIVE 命令记录

HIVE 命令记录

设置hive运行的队列
hive> set mapreduce.job.queuename=ven12;
打印列名
hive> set hive.cli.print.header=true;
创建新表
hive> CREATE TABLE t_hive (a int, b int, c int) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
正则匹配表名
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;
导入数据t_hive.txt到t_hive表
hive> LOAD DATA LOCAL INPATH '/home/cos/demo/t_hive.txt' OVERWRITE INTO TABLE t_hive ;
从其他表导入数据
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 '/home/test/fix_app_result.txt' select appid,count(1) from dpi_result_fix_list where appid<>'' and appid like '23%' group by appid;
创建视图
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;

转载于:https://www.cnblogs.com/lilin0719/p/6798734.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值