Deleting Data in PostgreSQL

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 users.

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 FALSE.

We use cookies and similar technologies to enhance the quality of services, maintain statistics and adjust marketing content. You will find more information in the Cookies Policy.

By clicking OK you grant consent to processing of your personal data by us and our Trusted Partners with the purpose of maintain statistics and adjustment of the marketing content pursuant to the Privacy Policy. If you wish to not grant that consent and/or limit its extent click Settings.