Deleting Tables

Now that you have seen how to add a table, you need to be able to remove or delete the table at the end of the lesson. To remove any object from the database, such as a table, you use the DROP operation. If you need to re-create a table or just remove it, you use the DROP TABLE statement as shown.

Drop table customer_demo

Caution

After you drop a table, it is gone forever. If you had a million rows in the table, they're gone. The server will let you drop a table even if it has rows in it. Unless you have a backup of the data, you have lost it completely.

Drop objects only when you are really sure that you don't need them.

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.