Hide records / Prepare for Removal
Tell the server that you want to:
- Mark records in a table for deletion (soft-delete)
- Keep it’s cache (any incrementing keys, indexes, data space)
- Some Database Management Systems will remove them completely
DELETE
FROM <schema_name>.<table_name>
WHERE <field1> = <value1>;
IMPORTANT:
- Deleting will remove existing data. Check before committing!
- If there is no WHERE clause, every row will be deleted.
- Not a pleasant feeling if done unintentionally!
stage_Product_Offers
Let's remove any offers from the stage_Product_Offers
table where:
- The offer started before 1st May 2021
DELETE
FROM "sequel-mart-schema"."stage_Product_Offers"
WHERE offer_start_date < '2021-05-01';
This removes the 3 offers from our table that started before 1st May 2021