Thursday, 18 September 2014

SQL DROP or DELETE Table

The SQL DROP TABLE statement is used to remove a table definition and all data, indexes, triggers,
constraints, and permission specifications for that table.
NOTE :- You have to be careful while using this command because once a table is deleted then all the information available in the table would also be lost forever.
Syntax :- 
Basic syntax of DROP TABLE statement is as follows :-

DROP TABLE table_name;

Example :-
Let us first verify CUSTOMERS table and then we would delete it from the database :-
This means CUSTOMERS table is available in the database, so let us drop it as follows :-

DROP TABLE CUSTOMERS;

Query OK, 0 rows affected (0.01 sec)
Now, if you would try DESC command, then you would get error as follows :-

DESC CUSTOMERS;

ERROR 1146 (42S02): Table 'TEST.CUSTOMERS' doesn't exist
Here, TEST is database name which we are using for our examples.

No comments:

Post a Comment