Delete the database underlying operating Hive, the partition table, table data

Basic Operation of the hive Delete database (database), the partition (partition), the table (table), the table data

1, delete the database

--  删除库
drop database if exists db_name;
--  强制删除库
drop database if exists db_name cascade;

2, delete the partition

2.1 Delete specific partition

-- 删除分区day_id=20200202
alter table tbl_name drop partition (day_id='20200202');
-- 批量删除分区
alter table tbl_name drop partition (day_id>='20200101',day_id<='20200202')

2.2 delete some information in the partition

3, delete the table

drop table if exists tbl_name;

4, delete the data in the table

Empty Table 4.1

-- 方式1
truncate table tbl_name;
-- 方式2
insert overwrite table tbl_name select * from tbl_name where 1=2; 

4.2 Delete Data (no partition table) conditional

insert overwrite table tbl_name select * from tbl_name where id<=100;
Published 22 original articles · won praise 22 · views 777

Guess you like

Origin blog.csdn.net/weixin_45568892/article/details/104780254