9951 explained code solutions for 126 technologies


postgresqlHow do I delete a row in PostgreSQL?


To delete a row in PostgreSQL, the DELETE statement is used. The DELETE statement requires the WHERE clause to identify the row to be deleted.

For example, the following statement deletes a row from the customers table with customer_id equal to 5:

DELETE FROM customers
WHERE customer_id = 5;

No output will be produced after executing the statement.

The parts of the code are as follows:

  • DELETE: the keyword used for deleting a row
  • FROM customers: the table from which the row is deleted
  • WHERE customer_id = 5: the condition used to identify the row to be deleted

Helpful links

Edit this code on GitHub