Hhive

在hive中的语句HQL的练习:
hive进去命令行:
看库:show databases;
建库/删库:create/drop schema hive 不是databases?
进库:use ku
看表:show tables;
建表:create table employee(id int, name string);不需要指定长度mysql需要
显示表结构:desc employee;
显示创建表的信息:show create table employee;
显示表名的分区show partitions 表名; 必须是分区表
删除库:库里有表时删不了库 一个方法是先删除表再删除库 第二种方法drop database 名字+ cascade
按住alt复制不复制尖头
create table employee(
name string,
address array,
personalInfo array,
technol map<string,int>,
jobs array<map<string,string>>)
row format delimited
fields terminated by ‘|’
collection items terminated by ‘,’
map keys terminated by ‘:’
lines terminated by ‘\n’;
上面有逗号 下面都没有
拖到左边 将表上传:hdfs dfs -put employee.txt /opt/hive/warehouse/a.db/employee
create table jobs_detail as
with
tmp as (select jobs from employee_partiton where info.gender=‘Male’),
t2 as (select jobs from employee_partiton where info.gender=‘female’)
select tmp.jobs male_job,t2.jobs female_job from tmp,t2;

临时表:temporary退出即删除文件夹 show create table 查看是否为临时表 desc 不行
create temporary table jobs_detail as
with
tmp as (select jobs from employee_partiton where info.gender=‘Male’),
t2 as (select jobs from employee_partiton where info.gender=‘female’)
select tmp.jobs male_job,t2.jobs female_job from tmp,t2;

create database hive_demo;
use hive_demo;
create external table employee(
name string,
id int,
phone string,
data string)
row format delimited
fields terminated by ‘|’
lines terminated by ‘\n’;

show create table employee;

create temporary table employee(
name string,
id int,
phone string,
data string)
row format delimited
fields terminated by ‘|’
lines terminated by ‘\n’;
location ’要去的文件夹‘!!!!!!!!

partitioned!!!
查看分区:show partitions 表
create table b (
name string,
id int,
phone string,
data string)
partitioned by (year string,month int)
row format delimited
fields terminated by ‘|’
lines terminated by ‘\n’;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值