5.8. SQL Delete

5.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;

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

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

5.8.4. Truncate

  • Removes all the data

  • Leaves table structure intact

TRUNCATE TABLE astronauts;

5.8.5. Drop

  • Removes all the data

  • Removes table too

DROP TABLE astronauts;