DELETE - delete rows of a table

SYNOPSIS

 

DELETE FROM [ ONLY ] table [ WHERE condition ]

DESCRIPTION Description

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

 

Tip: Tip: TRUNCATE [ TRUNCATE (7)] is a PostgreSQL extension that provides a faster mechanism to delete all the rows from a table.

 


 By default DELETE statement recording table and all its sub-table will be deleted. If you only want to update the table mentioned, you must use the ONLY clause.


 To delete a table, you must have DELETE privileges it, you must also have permission to SELECT, so as to meet the condition of the value of the read operation.

PARAMETERS Parameters

table

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

 Returns a boolean value expression type values, which determine which rows to be deleted.

OUTPUTS Output


 When successful, DELETE command returns the form

 

DELETE count


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

EXAMPLES Examples


 To delete all the movies (films) but does not delete the music (musicals):

 

DELETE FROM films WHERE kind <> 'Musical';


 Clear the table films:

 

DELETE FROM films;

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11080758.html
Recommended