SQL DELETE
The following command will delete all rows in the rent_payments
table where dollar_amount = 0
.
-- Works in PostgreSQL, MySQL, SQL Server, and Oracle
delete from rent_payments where dollar_amount = 0;
tenant
table before
id | name |
---|---|
1 | Albert |
2 | Marie |
3 | Jose |
4 | Terrell |
tenant
table after
id | name |
---|---|
1 | Albert |
2 | Marie |
If you want to delete all data in a table, just don’t use a filter. For example, delete from tenants;
would remove all data from the tenants
table.