Supported Versions: Current (15) / 14 / 13 / 12 / 11
Development Versions: devel
Unsupported versions: 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.



DELETE -- delete rows of a table


DELETE FROM [ ONLY ] table [ WHERE condition ]


DELETE deletes rows that satisfy the WHERE clause from the specified table. If the WHERE clause is absent, the effect is to delete all rows in the table. The result is a valid, but empty table.

Tip: TRUNCATE is a PostgreSQL extension that provides a faster mechanism to remove all rows from a table.

By default, DELETE will delete rows in the specified table and all its subtables. If you wish to delete only from the specific table mentioned, you must use the ONLY clause.

You must have the DELETE privilege on the table to delete from it, as well as the SELECT privilege for any table whose values are read in the condition.



The name (optionally schema-qualified) of an existing table.


A value expression that returns a value of type boolean that determines the rows which are to be deleted.


On successful completion, a DELETE command returns a command tag of the form

DELETE count

The count is the number of rows deleted. If count is 0, no rows matched the condition (this is not considered an error).


PostgreSQL lets you reference columns of other tables in the WHERE condition. For example, to delete all films produced by a given producer, one might do

  WHERE producer_id = AND = 'foo';

What is essentially happening here is a join between films and producers, with all successfully joined films rows being marked for deletion. This syntax is not standard. A more standard way to do it is

  WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');

In some cases the join style is easier to write or faster to execute than the sub-select style. One objection to the join style is that there is no explicit list of what tables are being used, which makes the style somewhat error-prone; also it cannot handle self-joins.


Delete all films but musicals:

DELETE FROM films WHERE kind <> 'Musical';

Clear the table films:



This command conforms to the SQL standard, except that the ability to reference other tables in the WHERE clause is a PostgreSQL extension.