The MySQL drop command is used to delete and entire table or database.
We saw earlier how to delete rows from a table in a database, but if we want to delete an entire table or even a whole database, we would have to use the drop command.
The MySQL drop command is potentially the most destructive MySQL command but the tutorial below will show you how to use it properly.
To delete an entire table from a database, we use the DROP TABLE command. The syntax is as follows:
DROP TABLE table_name;
So for example, if we wanted to delete a table called "employees" we would execute the following SQL:
DROP TABLE employees;
To delete an entire database from the MySQL server, we use the DROP DATABASE command. The syntax is fairly simple once again:
DROP DATABASE database_name;
So for example, if we wanted to delete an entire database which is called "company_records", we would execute the following SQL:
DROP DATABASE company_records;
Needless to say, the drop command is very destructive. You should use it with extreme care, and remember to backup the database before running queries which will perform modifications.
We hope this MySQL tutorial was helpful.