Tutorials

SQL Table


SQL Drop Table


In previous chapter we saw that any row from the table can be deleted using DELETE statement. 

But if we want to destroy the existence of entire table along with its definition then what to do?

 

DROP TABLE in sql is used drop all the rows in the table along with its definition. 

Once you execute DROP statement succesfully you are left with nothing. Niether the data in the table nor the table itself.

So think twice before dropping a table as you will never be able to use it again.

Syntax for DROP Table


DROP TABLE table_name;

Example on DROP table

We have a table named tih_Courses as shown below:

tih_Courses
Course_ID Course_Name Professor Mode_of_Training
001 .Net Mukesh Tiwari Online and Offline
002 Java Rajneesh Shukla Online and Offline
003 ANSI SQL Rajneesh Shukla Online
004 Basics of Computer Shweta  Online
 

 

We will apply DROP statement on this table.


DROP TABLE tih_Courses;

On executing the above query successfully, we will be left with neither the data in the table nor the the table itself.

To verify the same, execute below query


DESC tih_Courses;

DESC helps to check the table definition and its existence in database.

So executing it will show you no information about tih_Courses as the table is completely destroyed and doesnot exist in the database.



Please Share this page
Views : 49
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!