🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to PostgreSQL Notes
Topic #13

PostgreSQL DELETE


The DELETE Statement

The DELETE statement is used to delete existing records in a table.

Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record(s) should be deleted. If you omit the WHERE clause, all records in the table will be deleted!.

To delete the record(s) where brand is 'Volvo', use this statement:

Example

DELETE FROM cars
WHERE brand = 'Volvo';

Result

DELETE 1

Which means that 1 row was deleted.


Display Table

To check the result we can display the table with this SQL statement:

Example

SELECT * FROM cars;

Delete All Records

It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact.

The following SQL statement deletes all rows in the cars table, without deleting the table:

Example

DELETE FROM cars;

Result

DELETE 3

Which means that all 3 rows were deleted.


Display Table

To check the result we can display the table with this SQL statement:

Example

SELECT * FROM cars;

TRUNCATE TABLE

Because we omit the WHERE clause in the DELETE statement above, all records will be deleted from the cars table.

The same would have been achieved by using the TRUNCATE TABLE statement:

Example

TRUNCATE TABLE cars;

Result

TRUNCATE TABLE

Display Table

To check the result we can display the table with this SQL statement:

Example

SELECT * FROM cars;

Want to go beyond the notes?

Join CodingNow 2.0's PostgreSQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

PostgreSQL DELETE – FAQs

Quick answers about learning PostgreSQL DELETE in PostgreSQL.

This free note from CodingNow 2.0 explains PostgreSQL DELETE in PostgreSQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every PostgreSQL topic on CodingNow 2.0, including PostgreSQL DELETE, is 100% free with no signup required.
With focused practice, most students grasp PostgreSQL DELETE in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now