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

hive数据表创建

目录

分隔符

分区表 

 二级分区

分桶表

外部表


分隔符
CREATE TABLE emp(
userid bigint,
emp_name array<string>,
emp_date map<string,date>,
other_info struct<deptname:string, gender:string>)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
COLLECTION ITEMS TERMINATED BY ','
MAP KEYS TERMINATED BY ':';

FIELDS TERMINATED BY '\t'                             --字段之间的分隔符为制表符('\t')

COLLECTION ITEMS TERMINATED BY ','         --集合项之间的分隔符为逗号(',')

MAP KEYS TERMINATED BY ':'                         --MAP中每个键值对由冒号分隔

如:birth date:1953-11-07,from date:1990-01-22


分区表 
create table dept_partition(  
deptno int, dname string, loc string) 
partitioned by (day string) 
row format delimited fields terminated by '\t'; 

增加分区

alter table dept_partition add partition(day='20200404');alter table dept_partition add partition(day='20200405') partition(day='20200406'); 

删除分区

alter table dept_partition drop partition (day='20200406'); alter table dept_partition drop partition (day='20200404'), partition(day='20200405');  

删除partition内的部分信息(INSERT OVERWRITE TABLE

分区字段不能出现在查询字段中,即不能用select *

INSERT OVERWRITE TABLE emp_partition partition(dept_name='Finance')
SELECT 
emp_no,
first_name,
last_name,
gender,
birth_date,
from_date
FROM emp_partition
WHERE dept_name='Finance' and gender = "F";
 二级分区
create table dept_partition2(
deptno int, dname string, loc string ) 
partitioned by (day string, hour string)
row format delimited fields terminated by '\t'; 
分桶表
create table emp_bucket (
emp_no bigint,
first_name string,
last_name string,
gender string,
birth_date date,
from_date date,
dept_name string
)
clustered by(gender) into 2 buckets
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t';

clustered by(gender) 按照gender来分桶

into 2 buckets    分成多少个桶
外部表
--有自动创建文件夹功能
create external table emp_external(
emp_no bigint,
first_name string,
last_name string,
gender string,
birth_date date,
from_date date,
dept_name string
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
location '/user/admin/external_table/emp_external';

外部表和内部表的区别 

http://www.lryc.cn/news/189858.html

相关文章:

  • 查看本机Arp缓存,以及清除arp缓存
  • Unity MRTK Hololens2眼动交互
  • 接口自动化测试 —— 协议、请求流程
  • JDK安装详细教程
  • vulnhub_Fowsniff靶机渗透测试
  • FPGA面试题(3)
  • Avalonia常用小控件Menu
  • steam游戏服务器如何选择
  • 电脑技巧:推荐一款桌面整理神器TidyTabs
  • git合并分支-IDEA
  • winscope使用方法
  • 获取西华大学新闻网站信息(爬虫样例)
  • 【Linux】https协议
  • 基于工业5G网关的工业机器人监测控制方案
  • [Machine learning][Part4] 线性回归模型技巧
  • 产品经理进阶:如何写商业计划书?
  • Excel 规范录入数据
  • 使用IDEA自带功能将WSDL转java
  • Vue + moment 实现自定义日历
  • 【斗罗2】天梦哥抓捕冰帝,霍雨浩与她完美融合,喜提五挂
  • 上个月Balada Injector攻击中有超过17,000个WordPress网站被黑
  • python写一个文本处理器
  • unity发布微信小游戏,未找到 game.json报错原因
  • mysql进程信息出现大量Waiting for table level lock信息的原因,怎么处理?
  • Ubuntu不显示共享文件夹解决方案
  • canvas基础2 -- 形状
  • TCP/IP(五)TCP的连接管理(二)三次握手细节
  • Vue Elememt 链接后端
  • XPS光电子谱峰与俄歇电子谱峰-科学指南针
  • STM32F4X I2C LM75