A DROP TABLE IN SQL statement is used to delete or remove the table definition and all data from a table.
This is very important command to know that once a table is deleted or remove all the information available in the table is removed forever, so we have to be very careful when you use this command.
DROP TABLE "table_name";Let's take an example:
First we create students table then we delete it from the database.
SQL> DESC STUDENTS;FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA |
---|---|---|---|---|---|
ID | Int(11) | NO | PRI | ||
NAME | Varchar(25) | NO | |||
AGE | Int(11) | NO | |||
SUBJECT | Varchar(20) | YES | NULL | ||
MARKS | decimal(20, 2) | YES | NULL |
It shows that the data is store in database, so here we can remove or delete it as follows:
SQL>DROP TABLE STUDENTS;
Now to know whether the command in table exists or not:
SQL>DROP TABLE STUDENTS;
As you know that this command is dropped so it doesn't display in your screen.