6.8. SQL Delete

6.8.1. Delete One

  • Removes data from table

  • Leaves table structure intact

  • Can be narrowed down by a WHERE

DELETE FROM astronauts
WHERE id = 1;

6.8.2. Delete Many

  • Removes data from table

  • Leaves table structure intact

  • Can be narrowed down by a WHERE

DELETE FROM astronauts
WHERE agency = 'NASA';

6.8.3. 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';

6.8.4. Truncate

  • Removes all the data

  • Leaves table structure intact

TRUNCATE TABLE astronauts;

6.8.5. Drop

  • Removes all the data

  • Removes table too

DROP TABLE astronauts;