DELETESection: SQL Commands (7)Updated: 2003-11-02 |
DELETESection: SQL Commands (7)Updated: 2003-11-02 |
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.
By default, DELETE will delete rows in the specified table and all its subtables. If you wish to only delete 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.
On successful completion, a DELETE command returns a command tag of the form
DELETE countThe count is the number of rows deleted. If count is 0, no rows matched the condition (this is not considered an error).
Delete all films but musicals:
DELETE FROM films WHERE kind <> 'Musical';
Clear the table films:
DELETE FROM films;
This command conforms to the SQL standard.