The PostgreSQL DELETE Query is utilized to erase the current records from a table. You can utilize WHERE provision with DELETE question to erase the chose columns. Something else, all the records would be erased.
Syntax
The essential linguistic structure of DELETE question with WHERE provision is as per the following −
DELETE FROM table_name
WHERE [condition];
You can consolidate N number of conditions utilizing AND OR administrators.
Example
Think about the table COMPANY, having records as follows −
# select * from COMPANY;
id | name | age | address | salary
----+-------+-----+-----------+--------
1 | Paul | 32 | California| 20000
2 | Allen | 25 | Texas | 15000
3 | Teddy | 23 | Norway | 20000
4 | Mark | 25 | Rich-Mond | 65000
5 | David | 27 | Texas | 85000
6 | Kim | 22 | South-Hall| 45000
7 | James | 24 | Houston | 10000
(7 rows)
Coming up next is a model, which would DELETE a client whose ID is 7 −
testdb=# DELETE FROM COMPANY WHERE ID = 2;
Presently, COMPANY table will have the accompanying records −
id | name | age | address | salary
----+-------+-----+-------------+--------
1 | Paul | 32 | California | 20000
3 | Teddy | 23 | Norway | 20000
4 | Mark | 25 | Rich-Mond | 65000
5 | David | 27 | Texas | 85000
6 | Kim | 22 | South-Hall | 45000
7 | James | 24 | Houston | 10000
(6 rows)
On the off chance that you need to DELETE all the records from COMPANY table, you don't have to utilize WHERE condition with DELETE inquiries, which would be as per the following −
testdb=# DELETE FROM COMPANY;
Presently, COMPANY table doesn't have any record since all the records have been erased by the DELETE proclamation.