IT Training

Welcome to Lesson 7 of the TSQL Tutorial. In this lesson we will cover drop statements. I hope you enjoy the lesson.

Select Statements

DROP

The DROP statement is used to remove (delete) a database, table, or index.

Usage: you can drop database by

DROP DATABASE databasename
Example: We want drop database called Northwind.
DROP DATABASE Northwind
...example: to drop the employees table
DROP employees
...example: to drop the index firstname in the employees table.
DROP INDEX employees.ind_firstfame

 

Note that in SQL, there is a big difference between the delete and drop statement.

DELETE is used to delete row(s) in a table.

DROP is used to removes a database, table or index definition.  Removes object from existence.

...to make things more confusing, there is also TRUNCATE. 

TRUNCATE is used to delete all rows in a particular table.  SQL Server does not log the individual row deletes in a trucate statement, which makes it much faster than a delete statement