[MySQL Tutorial 9] Deleting Table


In the previous MySQL tutorial on Updating Table, you learnt how to update values inside an existing table. In this tutorial, you will learn how to delete a table you don’t want in the database.

We may need to delete an unwanted table in the database. To delete a table, use drop command. Drop command is also used to delete a database as described in [MySQL Tutorial 3] Creating Database

Let us create a table name “waste” that we’ll be using for checking the drop command. The syntax for drop command is:

Drop table table_name;

For example,

Create table waste (col1 int, col2 int);

Drop table waste;


Using PHP:

$link=mysql_connect('localhost','root','your password');
echo "connected to mysql"."<br>";
$r=mysql_query('Drop table employee');
echo "table dropped";
echo "not dropped";

The output is:

Now that you know how to delete table, continue with the next tutorial on how to sort your query using WHERE, LIKE and ORDER BY clauses. Also, If you have any queries, please leave a comment below.


Leave A Reply