Hive常用的命令有哪些?

提问者:帅平 问题分类:大数据
Hive常用的命令有哪些?
19 个回答
`小囡
`小囡
hive表中数据导出:
#将查询的结果导出到本地
insert overwrite local directory '/export/servers/exporthive' select * from score;
#将查询的结果格式化导出到本地:
insert overwrite local directory '/export/servers/exporthive' row format delimited fields terminated by '\t' collection items terminated by '#' select * from student;
#将查询的结果导出到HDFS上(没有local):
insert overwrite directory '/export/servers/exporthive' row format delimited fields terminated by '\t' collection items terminated by '#' select * from score;
#export导出到HDFS上
export table score to '/export/exporthive/score';
发布于:1个月前 (03-18) IP属地:
满天都是派星べ
满天都是派星べ
向hive表中加载数据:
#直接向分区表中插入数据:
insert into table score partition(month ='202107') values ('001','002','100');
#通过load方式加载数据:
load data local inpath '/export/servers/hivedatas/score.csv' overwrite into table score partition(month='201806');
#通过查询方式加载数据:
insert overwrite table score2 partition(month = '202106') select s_id,c_id,s_score from score1;
#查询语句中创建表并加载数据:
create table score2 as select * from score1;
#在创建表是通过location指定加载数据的路径:
create external table score6 (s_id string,c_id string,s_score int) row format delimited fields terminated by ',' location '/myscore';
#export导出与import 导入 hive表数据
create table techer2 like techer; --依据已有表结构创建表
export table techer to '/export/techer';
import table techer2 from '/export/techer';
发布于:1个月前 (03-18) IP属地:
娇喘界的扛把子
娇喘界的扛把子
清空表:
truncate table score6;
发布于:1个月前 (03-18) IP属地:
ε小可爱з
ε小可爱з
删除表:
drop table score5;
发布于:1个月前 (03-18) IP属地:
美到拖网速
美到拖网速
强制删除数据库:
drop database myhive2 cascade;
发布于:1个月前 (03-18) IP属地:
别活的像别人
别活的像别人
删除空数据库:
drop database myhive2;
发布于:1个月前 (03-18) IP属地:
穿越到古代找美女
穿越到古代找美女
添加分区:
alter table table_name add partition (dt='2021-11-30');
发布于:1个月前 (03-18) IP属地:
心已打烊
心已打烊
删除分区:
alter table table_name drop partition(dt='2021-11-30');
发布于:1个月前 (03-18) IP属地:
满天都是派星べ
满天都是派星べ
hive修改字段:
alter table table_name change old_column new_column string comment 'comm_text';
发布于:1个月前 (03-18) IP属地:
浅语望月
浅语望月
hive添加字段:
alter table table_name add columns(columns_values bigint comment 'comm_text');
发布于:1个月前 (03-18) IP属地:
也不长发及腰
也不长发及腰
hive复制表结构:
create table new_table_name like table_name;
发布于:1个月前 (03-18) IP属地:
我是白云
我是白云
hive修改表名:
alter table old_table_name rename to new_table_name;
发布于:1个月前 (03-18) IP属地:
渡不过的奈何桥
渡不过的奈何桥
创建表时指定的一些属性:
#字段分隔符:
row format delimited fields terminated by '\t'
#行分隔符:
row format delimited lines terminated by '\n'
#文件格式为文本型存储:
stored as textfile
发布于:1个月前 (03-18) IP属地:
艺兴一意
艺兴一意
导出数据到本地系统:
insert overwrite local directory '/tmp/text' select a.* from table_name a order by 1;
发布于:1个月前 (03-18) IP属地:
酷的没边儿
酷的没边儿
从查询语句给table插入数据:
insert overwrite table table_name partition(dt) select * from table_name;
发布于:1个月前 (03-18) IP属地:
本姑娘贼稳妥
本姑娘贼稳妥
加载本地文件:
load data local inpath '/xxx/test.txt' overwrite into table dm.table_name;
发布于:1个月前 (03-18) IP属地:
`小囡
`小囡
查看分区信息:
show partitions table_name;
发布于:1个月前 (03-18) IP属地:
拜你所赐
拜你所赐
查看表结构信息:
desc table_name;
发布于:1个月前 (03-18) IP属地:
自然萌鹿鹿
自然萌鹿鹿
hive模糊搜索表:
show tables like '*name*';
发布于:1个月前 (03-18) IP属地:
我来回答