栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Hive使用中经常用到的SQL

Hive使用中经常用到的SQL

1.表创建 1.1方式1
create table  t1(
org_id int,
banner string,
pv int,
uv int)
partitioned by(day_id string) ##分区
row format delimited fields terminated  by 't'
stored as textfile;
1.2方式2
create table  t2 as select * from t1;
1.3方式3
create table t2 like t1;
2.表数据导出
hdfs dfs -rm /file1/fqw/*
beeline -e "insert overwrite directory '/file1/fqw/' row format delimited fields terminated by 't' select * from t1"
hdfs dfs -cat /file1/fqw/ >sichuan.txt
3.表数据导入
hdfs dfs -put /file1/fqw/d1.dat /user/hive/warehouse/表名
4.表重命名
alter table oldname rename to newname;
5.表字段修改
alter table t1 change column  oldcolumn newcolumn 数据类型;
6.增加字段
alter table t1 add columns(fields 数据类型);
7.新增和删除分区
alter table t1 add partition(dt='');
alter table t1 drop partition(dt='');
8.向分区表插入数据
insert into table t1 partition(dt='')
select * from t2;
9.shell脚本中添加hivesql
#加入单条sql语句
beeline -e " "
#加入多条sql语句
beeline < 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/700360.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号