DELETE

功能描述

DELETE从指定的表里删除满足WHERE子句的行。如果WHERE子句不存在,将删除表中所有行,结果只保留表结构。

注意事项

  • 本章节只包含spqplugin新增的多机并行功能,原openGauss的语法未做删除和修改。

示例

--创建表t1。
openGauss=# create table t1(c1 int, c2 char);
CREATE TABLE
openGauss=# insert into t1 values(1, 'a');
INSERT 0 1

--开启spq delete。
openGauss=# set spqplugin.enable_spq = on;
SET
openGauss=# set spqplugin.spq_optimizer_enable_dml = true;
SET
openGauss=# set spqplugin.spq_enable_delete = on;
SET
openGauss=# set query_dop = 2;
SET
--查看多机计划。
openGauss=# explain delete from t1 where c1 = 1;
                                              QUERY PLAN
---------------------------------------------------------------------------------------------------
 Streaming (type: GATHER)  (cost=0.00..0.00 rows=0 width=1)
   ->  Delete on t1  (cost=0.00..431.01 rows=1 width=1)
         ->  SPQ Result  (cost=0.00..431.00 rows=1 width=22)
               ->  Streaming(type: DML REDISTRIBUTE dop: 1/2)  (cost=0.00..431.00 rows=1 width=11)
                     ->  Spq Seq Scan on t1  (cost=0.00..431.00 rows=1 width=11)
                           Filter: (c1 = 1)
(6 rows)

--删除表。
openGauss=# drop table t1;

相关链接

DELETE

意见反馈
编组 3备份
    openGauss 2024-10-14 01:18:03
    取消