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

提交您的网站网站开发样板

提交您的网站,网站开发样板,黑龙江交通系统网站建设,企业网站属于下面哪种媒体类型目录 建表语句 表数据 Hive建表高阶语句 - CTAS and WITH CTAS – as select方式建表 CTE (CTAS with Common Table Expression) LIKE 创建临时表 清空表数据 修改表(Alter针对元数据) 改名 修正表文件格式 修改列名 添加列 替换列 动态分…

目录

建表语句

表数据

Hive建表高阶语句 - CTAS and WITH

CTAS – as select方式建表

CTE (CTAS with Common Table Expression)

LIKE

创建临时表

清空表数据

修改表(Alter针对元数据)

改名

修正表文件格式

修改列名

添加列

替换列

动态分区

使用动态分区需设定属性

建表语句

 动态分区插入数据

查询分区

 添加分区

删除分区


建表语句

create table if not exists employee
(name         string,workplace    array<string>,gender       string,age          int,skills_score map<string,int>,depart_title map<string,string>
) row format delimited fields terminated by '|'collection items terminated by ','map keys terminated by ':'lines terminated by '\n';

表数据

Michael|Montreal,Toronto|Male|30|DB:80|Product:Developer Lead
Will|Montreal|Male|35|Perl:85|Product:Lead,Test:Lead
Shelley|New York|Female|27|Python:80|Test:Lead,COE:Architect
Lucy|Vancouver|Female|57|Sales:89,HR:94|Sales:Lead

Hive建表高阶语句 - CTAS and WITH

CTAS – as select方式建表

CREATE TABLE ctas_employee as SELECT * FROM employee;

CTAS不能创建partition, external, bucket table

CTE (CTAS with Common Table Expression)

CREATE TABLE cte_employee AS
WITH
r1 AS  (SELECT name FROM r2 WHERE name = 'Michael'),
r2 AS  (SELECT name FROM employee WHERE gender= 'Male'),
r3 AS  (SELECT name FROM employee  WHERE gender = 'Female')
SELECT * FROM r1 UNION ALL SELECT * FROM r3;

LIKE

CREATE TABLE employee_like LIKE employee;

创建临时表

临时表是应用程序自动管理在复杂查询期间生成的中间数据的方法

表只对当前session有效,session退出后自动删除

表空间位于/tmp/hive-<user_name>(安全考虑)

如果创建的临时表表名已存在,实际用的是临时表

CREATE TEMPORARY TABLE tmp_table_name1 (c1 string);

CREATE TEMPORARY TABLE tmp_table_name2 AS..

CREATE TEMPORARY TABLE tmp_table_name3 LIKE..

清空表数据

TRUNCATE TABLE employee; 

修改表(Alter针对元数据)

改名

ALTER TABLE employee RENAME TO new_employee;

修正表文件格式

ALTER TABLE employee SET FILEFORMAT RCFILE; 

修改列名

ALTER TABLE employee CHANGE name  employee_name STRING; 

添加列

ALTER TABLE employee ADD COLUMNS (work string);

替换列

ALTER TABLE employee REPLACE COLUMNS (name string);

创建分区

动态分区

使用动态分区需设定属性

set hive.exec.dynamic.partition=true;

set hive.exec.dynamic.partition.mode=nonstrict;

建表语句

create table employee_dt(name         string,workplace    array<string>,skills_score map<string,int>,depart_title map<string,string>
) partitioned by (gender string,age int )row format delimited fields terminated by ','collection items terminated by '-'map keys terminated by ':'lines terminated by "\n";

 动态分区插入数据

insert into table employee_dt partition (gender,age)
select name, workplace, skills_score, depart_title, gender, age
from employee2;

查询分区

show partitions employee_dt;

 添加分区

alter table employee_dtadd partition (gender = "Male",age = 28);

 

删除分区

alter table employee_dtdrop partition (gender = "Male",age = 28);

http://www.yayakq.cn/news/287918/

相关文章:

  • 达州网站建设的公司企业网站托管费用
  • php网站开发概念温州seo优化排名公司
  • 无法访问服务器上网站传奇网页游戏排行
  • 织梦高端大气网站模板北京市工商注册登记网
  • 响应式网站适合优化吗卖房网站母亲节做什麽活动
  • 建筑人才网官方网站查询如何制作app软件演示教程
  • 做网站的数据库的步骤找个小网站
  • 完全免费空间网站住房和城乡建设部证书查询
  • 做网站可以用海外空间吗站内关键词排名优化软件
  • 南昌做网站价格私密浏览器免费版在线看视频下载
  • asp.net 网站 相册网站后台修改内容看不见了
  • 网站建设需要会什么软件有哪些方面wordpress FTP媒体库
  • 移动通网站建设商洛网站建设哪家好
  • 网站开发做原型吗做民宿推广都有哪些网站
  • 广告设计制作公司网站购物网站开发教案
  • 连云港市建设工程质量监督站网站公司微信网站开发平台
  • 如何管理企业网站网站seo跟短视频
  • 广州微型网站建设当面付 wordpress插件
  • 世界杯网站源码下载高校网站建设资料库
  • 公司做网站那个网站好做网站的项目实施方案
  • 网站域名切换高仿卡地亚手表网站
  • 网站建设业务员培训wordpress添加优酷视频播放
  • 去什么网站做推广创意产品网站
  • 东八区网站建设用wex5可以做网站吗
  • 做网站用什么开源程序网站建设工作室深圳
  • 网站建设运营法律风险防范网站里的搜索怎么做
  • 如何做文化传播公司网站怎么在网站上做按钮
  • 三合一网站建设官网seo外包一共多少钱
  • 潍坊住房和城乡建设局招标网站2023年阳性最新上班政策
  • wordpress 硬件要求长沙专业网站优化定制