What is Deleting Data in PostgreSQL?
Deleting data from Postgres database table means removing entire rows or row from that table.
Removing All Rows from a Given Table
To delete all rows from a given table use the
DELETE command appended with the table name and without providing any conditions regarding the rows to delete.
DELETE FROM users;
The above command removes all rows from the table
Removing Only Specific Rows from a Given Table
It is possible to delete only rows meeting specific criteria. The criteria (conditions) are provided using the key word
WHERE appended with a boolean expression which can reference cell values of the table rows.
DELETE FROM products WHERE fit_for_consumption = FALSE;
The above command removes only those rows from
products which have the column
fit_for_consumption value set to