MAPREDUCE服务 MRS-TRUNCATE TABLE:示例

时间:2024-07-02 16:40:05

示例

-- 删除原生/管控表
Create table simple(id int, name string);
 
Insert into simple values(1,'abc'),(2,'def');
 
select * from simple;
 id | name
----|------
  1 | abc
  2 | def
(2 rows)
 
Truncate table simple;
 
select * from simple;
 id | name
----|------
(0 rows)
 
--删除表分区
Create table tb_truncate_part (id int, name string) partitioned by (age int, state string);
 
Insert into tb_truncate_part values (1,'abc',10,'ap'),(2,'abc',10,'up'),(3,'abc',20,'ap'),(4,'abc',20,'up');
 
select * from tb_truncate_part;
 id | name | age | state
----|------|-----|-------
  2 | abc  |  10 | up
  3 | abc  |  20 | ap
  1 | abc  |  10 | ap
  4 | abc  |  20 | up
(4 rows
 
Truncate table tb_truncate_part partition (state = 'ap', age = 10);
 
select * from tb_truncate_part;
id | name | age | state
----|------|-----|-------
  4 | abc  |  20 | up
  2 | abc  |  10 | up
  3 | abc  |  20 | ap
(3 rows)
support.huaweicloud.com/cmpntguide-lts-mrs/mrs_01_300147.html