当前位置: 首页 > news >正文

Hive编程(一)

数据库操作:

数据仓库的创建:

create database (if not exist)hivedwd;

创建时添加键值对信息:

create dabatase hivedwh with dbproperties(‘owner’=‘itcast’,‘data’=‘2021’);

数据仓库显示:

show databases;

显示仓库详细信息:

describe database extended hivedwh;

切换数据仓库:

use hivedwh;

数据仓库的修改:

alter database hivedwh  set dbproperties(‘createtime’=‘20210112’);

数据仓库的删除:

drop database hivedwh;

数据仓库强制删除:

drop database (if exists)hivedwh cascade;

数据库中表的操作:

内部表:

创建内部表:

create table table_1(id int,name string);

向表中插入数据:

insert into table_1 values (1,"张三");

创建内部表并指定字段之间的分隔符:

create table table_1(id int,name string) row format delimited fields terminated by '\t';

创建表并指定放入的路径:

create table if not exists table_1 row format delimited fields terminated by '\t' location '/user/stu2'; 

根据查询结果创建表:

create table if not exists table_1 as select * from stus

根据已经存在的表创建新的表:

create table table_1 like stu1;

查看表的详细信息:

desc formatted table_1;

删除表:

drop table table_1;

外部表:

创建外部表:

create external table if not exists table_1 (id int,name string) row format delimited fields terminated by '\t';

加载数据:

load data local inpath "文件路径" into table table_1;

加载数据并覆盖已有数据:

load data local inpath "文件路径"  overwrite into table table_1;

分区表:

创建分区表:

create table if not exists table_1(id int , name string) partitioned by (month string)  row format delimited fields terminated by'\t';

创建一个表带多个分区:

create table if not exists table_1(id int ,name string) partitioned by(month int,day string) row format delimited fields terminated by '\t';

多分区表联合查询:(union all)

select * from table_1 where month = '2021' union all select * from table_1 where month = '2020'

查看分区:

show partitions table_1;

添加一个分区:

alter table table_1 add partition(month='2021');

删除一个分区:

alter table table_1 drop partition(month='2021')

分桶表:

创建分桶表:

set hive.enforce.bucketing=true;

设置Reduce个数:

set mapreduce.job.reduce=3;

创建分桶表:

create table course (c_id string,c_name string,t_id string) clustered by(c_id) into 3 buckets row format delimited fields termainated by '\t';

数据加载时需要常见普通表,使用insert overwrite的方法进行加载数据

相关文章:

  • Spring Security介绍
  • js日期排序(使用sort)
  • 音视频中的DTS和PTS区别
  • 【数据库和表的管理】
  • 人大金仓 KingBase 表添加自增主键
  • Hadoop分布式文件系统(三)
  • Java复习
  • 学习笔记:在华为昇腾NPU上进行深度学习项目【未完待续】
  • 【Linux】各目录说明
  • Microsoft Remote Desktop for Mac 中文正式版下载 微软远程连接软件
  • 【linux驱动开发】在linux内核中注册一个杂项设备与字符设备以及内核传参的详细教程
  • 阿里云高性能云服务器_云主机_云服务器详解
  • 初识 Elasticsearch 应用知识,一文读懂 Elasticsearch 知识文集(4)
  • 59道SpringCloud面试题详解含答案(值得珍藏)
  • 多线程——定时器
  • JS中 map, filter, some, every, forEach, for in, for of 用法总结
  • 0基础学习移动端适配
  • Android框架之Volley
  • CentOS7简单部署NFS
  • JavaScript HTML DOM
  • Java基本数据类型之Number
  • Spring Cloud Feign的两种使用姿势
  • yii2中session跨域名的问题
  • 复杂数据处理
  • 关于字符编码你应该知道的事情
  • 利用DataURL技术在网页上显示图片
  • 利用jquery编写加法运算验证码
  • 学习Vue.js的五个小例子
  • 优化 Vue 项目编译文件大小
  • Spring Batch JSON 支持
  • 移动端高清、多屏适配方案
  • ​linux启动进程的方式
  • ​VRRP 虚拟路由冗余协议(华为)
  • ​用户画像从0到100的构建思路
  • (day 2)JavaScript学习笔记(基础之变量、常量和注释)
  • (八十八)VFL语言初步 - 实现布局
  • (附源码)springboot宠物医疗服务网站 毕业设计688413
  • (论文阅读11/100)Fast R-CNN
  • (十八)SpringBoot之发送QQ邮件
  • (四)搭建容器云管理平台笔记—安装ETCD(不使用证书)
  • (转)EXC_BREAKPOINT僵尸错误
  • (轉)JSON.stringify 语法实例讲解
  • .bat批处理(十一):替换字符串中包含百分号%的子串
  • @EnableWebMvc介绍和使用详细demo
  • [2019/05/17]解决springboot测试List接口时JSON传参异常
  • [C++]类和对象【下】
  • [Gym-102091E] How Many Groups
  • [IE编程] IE中对网页进行截图的编程接口
  • [javaee基础] 常见的javaweb笔试选择题含答案
  • [Kubernetes]8. K8s使用Helm部署mysql集群(主从数据库集群)
  • [LeetCode] 148. Sort List 链表排序
  • [LeetCode]Spiral Matrix
  • [Linux] Ubuntu install Miniconda
  • [luogu4162 SCOI2009] 最长距离(最短路)
  • [python3] 装饰器