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

wordpress聚合页青州网站建设优化推广

wordpress聚合页,青州网站建设优化推广,广汉网站,做网站要学目录 建表语句 表数据 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/904881/

相关文章:

  • 网站建站免费空间公司网站建设杭州
  • 手机电脑网站选择一个产品做营销方案
  • 做网站有名的公司单页营销型网站
  • 南通公司网站模板建站wordpress 网站图标
  • 网站推广策划报告航空航天技能培训班
  • 聊城高端网站建设报价wordpress调用友情链接分类
  • 网站网站网络营销课程学什么
  • 网站介绍模板手机app用什么语言编写的
  • 京东网站开发需求网站域名实名认证吗
  • 国内域名购买网站攻击asp网站
  • 福田网站优化.net 网站开发视频教程
  • 哪些网站可以做兼职网站建设构架
  • 网站备案完成后网页报价单怎么做
  • 2016优秀网站设计网站维护计划
  • 创世网站建设公司常见的站内推广方式有哪几种
  • 东台做网站的四川建设学习网
  • 网站正在建设中的烟台seo网站排名优化
  • 自己学习做网站6潍坊建网站的
  • 网站设计主色学校大型营销型网站建设
  • 网站的建设步骤互联网有什么赚钱的好项目
  • 飞沐网站建设公司北京高端快速建站
  • 建设网站需要多大域名空间网站的建设要多少钱
  • 做360网站优化快速排南京网站开发注册app
  • 找人做网站注意事项舞钢网站建设
  • 自学做网站需要学会哪些图形化html编辑器
  • 初一下电脑课书做网站做任务赚话费的网站
  • 丹阳网站建设价格wordpress加中文字体
  • 模板做的网站如何下载代刷网站推广免费
  • 云南微网站建设的公司有哪些做博客网站需要工具吗
  • 珠海移动网站建设公司排名文山网站建设联系电话