第1關:Hive -- 索引
---創建mydb數據庫
create database if not exists mydb;
---使用mydb數據庫
use mydb;
---------- Begin ----------
---創建staff表
create table staff(
id int,
name string,
sex string)
row format delimited fields terminated by ','
stored as textfile;
---導入數據:/root/staff.txt
load data local inpath '/root/staff.txt' into table staff;
---創建staff表索引:索引名稱為staff_index,索引字段為id,創建索引后的表:sta
create index staff_index
on table staff(id)
as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'
with deferred rebuild
in table sta;
---生成索引數據并查看sta索引表數據
alter index staff_index on staff rebuild;
select * from sta;
---查看索引
show index on staff;
---刪除索引后再查看索引
drop index staff_index on staff;
show index on staff;
---------- End ----------
---清空staff表
truncate table staff;
---刪除staff表
drop table staff;
第2關:Hive -- 動態分區調整
---創建mydb數據庫
create datab