一、建表
create table tmp(id string, name string)
二、插入数据
1、直接插入
insert into tmp values ("1","a"), ("2","b"),("3","c")
2、从已有表插入
insert into table tmp
select id, nm from tmp_a where 约束条件
三、删除表
1、删除表(表不再存在)
drop table if exists tmp
2、删除表中数据(表结构保持不变)
truncate table tmp
四、复制表结构及表数据
CREATE TABLE tmp_copy AS SELECT * FROM tmp
五、建索引
--建立索引
create index index_id on table tmp(id)
as 'org.apache.hadoop.hive.ql.index.compact.CompactIndexHandler'
with deferred rebuild
IN TABLE tmp_index
alter index index_id on tmp rebuild
--查看索引
select * from tmp_index limit 5
show index on tmp