Hive学习实战
--------------------------------------------------------------
Hive从入门到实战【40讲】---笔记记录
--------------------------------------------------------------
hive命令
1、show tables;
2、show databases;
3、 desc login; ---查看表结构。
4、 show partitions test5; --查看分区
第16天: 增加分区、删除分析、加载数据到指定分区讲解和案例操作---
添加分区
alter table table_name
add partiton( partCol='value1' ) location 'loc1';
删除分区
alter table login drop if exists partition (dt='2008-08-08');
alert table page_view drop if exists partition(dt=2008-08-08
',country='us');
添加列
alter table table_name add columns (
col_name string); //在所有存在的列后面,但是
在分区列之前添加一列。
create table test5(
uid string,
ip string
)
partitioned by (dt string,hour string)
row format delimited
fields terminated by ','
stored as textfile;
alter table test5
add partition (dt='2015-02-08',hour='08')
location '/hive/test5/dt=2015-02-08/hour=09'
partition (dt='2015-02-08',hour='09')
location '/hive/test5/dt=2015-02-08/hour=10'
load data local inpath '/hadoop/hive0.9/testHive/x1.txt' into table test5
partition(dt='2015-02-08',hour='09')
--------------------------------------------------------------
Hive从入门到实战【40讲】---笔记记录
--------------------------------------------------------------
hive命令
1、show tables;
2、show databases;
3、 desc login; ---查看表结构。
4、 show partitions test5; --查看分区
第16天: 增加分区、删除分析、加载数据到指定分区讲解和案例操作---
添加分区
alter table table_name
add partiton( partCol='value1' ) location 'loc1';
删除分区
alter table login drop if exists partition (dt='2008-08-08');
alert table page_view drop if exists partition(dt=2008-08-08
',country='us');
添加列
alter table table_name add columns (
col_name string); //在所有存在的列后面,但是
在分区列之前添加一列。
create table test5(
uid string,
ip string
)
partitioned by (dt string,hour string)
row format delimited
fields terminated by ','
stored as textfile;
alter table test5
add partition (dt='2015-02-08',hour='08')
location '/hive/test5/dt=2015-02-08/hour=09'
partition (dt='2015-02-08',hour='09')
location '/hive/test5/dt=2015-02-08/hour=10'
load data local inpath '/hadoop/hive0.9/testHive/x1.txt' into table test5
partition(dt='2015-02-08',hour='09')