9.15. SQL Delete

9.15.1. Rationale

9.15.2. Delete One

  • Removes data from table

  • Leaves table structure intact

  • Can be narrowed down by a WHERE

DELETE FROM astronauts
WHERE id = 1;

9.15.3. Delete Many

  • Removes data from table

  • Leaves table structure intact

  • Can be narrowed down by a WHERE

DELETE FROM astronauts
WHERE agency = 'NASA';

9.15.4. Delete Query

  • Removes data from table

  • Leaves table structure intact

  • Can be narrowed down by a WHERE

DELETE FROM astronauts
WHERE firstname = 'Mark'
AND lastname = 'Watney';

9.15.5. Truncate

  • Removes all the data

  • Leaves table structure intact

TRUNCATE TABLE astronauts;

9.15.6. Drop

  • Removes all the data

  • Removes table too

DROP TABLE astronauts;