本小节将会为您介绍交互式分析中delete命令的用法。

命令功能介绍

delete:对表指定列的行数据进行删除。

命令格式

在交互式分析中delete的命令格式如下:

DELETE FROM table_name [ * ] [ [ AS ] alias ]
    [ WHERE condition  ]

参数

  • alias:别名,目标表的替代名称。
  • condition:删除的条件。

示例用法

在交互式分析中delete的示例用法如下。

CREATE TABLE delete_test (
    id INT PRIMARY KEY,
    a INT,
    b text 
);

INSERT INTO delete_test VALUES 
(1, 10, 'a'),
(2, 30, 'b'),
(3, 50,  ''),
(4, 70, null);



DELETE FROM delete_test AS dt WHERE dt.a = 10;

DELETE FROM delete_test AS dt WHERE dt.b is null;

DELETE FROM delete_test AS dt WHERE dt.b='';
633

更多关于delete的详情请参见PostgreSQL官网文档

使用限制

  • 暂不支持对分区父表直接delete,需要delete具体的分区子表。