In SQL there are 3 commands that are used to remove data from a database. Although they remove data, they have major differences.
Let’s assume we have a database call school and with in that school we have table call class, within this class we have a bunch of records of students that attend this class.
Drop command
drop table class;
The drop command will delete the whole table class, it will delete all of the records and the table structure from the database.
Delete command
#assuming student_id is a field of class
Delete from class
where student_id = 5;
The delete command is used to delete specific records from a table. In our example above it will only delete the record where student_id is 5.
Truncate command
Truncate table class;
The truncate command removes all the records of a table, with out dropping the table structure.