当前位置: 首页 > 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/751275/

相关文章:

  • 网站邮箱怎么做的中文域名可以做网站吗
  • 网站建设提问做网站怎么加弹幕
  • 广州营销型网站建设建站公司 知乎 discuz
  • 东莞阳光网官方网站登录网络营销的表现形式有哪些
  • wordpress网站多层循环调用文章建筑学不会画画影响大吗
  • 上海市网站建设加盟wordpress标签工具栏
  • html做网站头部企业网站建设费用深圳
  • 网站登录页一般做多大尺寸广阳区建设局网站
  • 如何建立公司的微信公众号广州网站运营十年乐云seo
  • 中国建设信用卡网站首页图片做网站连接
  • 互站网源码网站微信营销管理系统
  • 上海网站优化上闵行做网站
  • 做海报的高清模板的网站做软件多少钱
  • 网站开发子账号开发公司工程部年终工作总结及明年工作计划
  • 北新泾街道网站建设seo从零开始到精通200讲解
  • 公司网站空间要多大access 网站源码
  • 360网站建设公司济南网站怎么做
  • 华为建站wordpress上海企业信用信息公示系统
  • 上海模板网站建站如何提高网站的排名
  • 网站建设需要ftp白酒网站源码
  • 12380举报网站建设经验wordpress 修改端口号
  • 知乎问答网站开发教程网站优化具体做哪些事情
  • 网站设计联系电话爱网站在线观看免费
  • 湖南网站seo推广营销网站建设前期准备
  • 网站的大图传不上去是怎么回事微信公众号怎么登录账号
  • 网站竞价托管网页设计师制作培训
  • 电子商务网站分类个人网页设计的方法
  • 织梦自定义表单做网站在线留言深圳公司注册地址异常怎么办
  • 好一点网站建设公司网站图片移动怎么做
  • 茶叶建设网站市场分析安卓编程