Free Web Development Online Tutorials, Learn to Code
Learn SQL Table Drop Statement, how to Drop Table in SQL Database

SQL Drop Table Statement Example

Learn how to delete a SQL table from database permanently, SQL Drop Table Statement Example

Drop Table in SQL

Here you learn how to drop a table in SQL Server.

Remember that once you drop a table all data in that table will be lost, so be careful before executing Drop statement in SQL Server.

Drop is like you are deleting the object permanently from SQL Server, but in SQL Delete is considered as query statement.

So , here is how you can Drop a table.

// drop TABLE [schemaName].[tableName]
drop TABLE [dbo].[tbTeacher]

If you want to just delete the data , think of delete or truncate but don’t drop the table.

If the table is referenced by FOREIGN KEY Constraint, then it will not allow you to drop the table, and throw an exception "Could not drop object 'table' because it is referenced by a FOREIGN KEY constraint"

If you get the above error while dropping a table, you need to delete the Foreign Key Constraint first, then will be able to drop the table.

ALTER TABLE ClassStudentMap
DROP CONSTRAINT FK_ClassStudentMap_ClassRoom;
Drop Table Example in SQL Database

SQL job Interview Questions Answers

Course in Demand
MS SQL Examples | Join MS SQL Course