This document discusses how to delete data of a table using PostgreSQL DELETE command.
Following is the usage of PostgreSQL DELETE command to delete data of a PostgreSQL table.
DELETE FROM table_name ;
Where table_name is the associated table. Executing this command will delete all the rows of the associated table.
DELETE FROM table_name WHERE condition;
If you don't want to delete all of the rows of a table, but some specific rows which match the "condition", execute the above.
DELETE all rows of table
Structure of the table
Following is the structure of the table whose data will be deleted.
Data Before deletion
Command to delete data
DELETE FROM book;
This command will delete all of the rows of the book table.
DELETE specific rows of a table
DELETE FROM book WHERE price < 25.00
This command will delete all the rows, which stores information about a book, whose price is less than 25.00.
Many of our valued users post comments along with piece of code. Disqus may, false positively, consider those piece of code as Bad or Starnge syntax and send those comments to spam automatically. Even if that happens, we will make sure those useful comments are taken out of spam and approved. It may take a couple of days for that though, but any useful comment will be brought to public view for sure. We regret if that happend to any user. You may write us directly regarding this to - w3resource[at]yahoo[dot]com.