Occasionally you might experience a Joomla! extension that does not uninstall properly. This can happen for many reasons and if it needs to be removed, it must be removed manually. Other instances might be where you uninstalled an extension, but it left behind its tables intentionally yet they need to be removed for any number of reasons.
In this recipe we will look at the command line method to delete or remove a table. The term is 'drop' which means delete or remove. We will remove an imaginary extension table from our database called jos_Corn_Syrup. The situation is we have removed our extension called Corn Chart, used to track the corn fields for farmers. However, the programmer wrote our extension so that it purposely leaves behind the tables for upgrades, and so on. This is a common (and good) practice.
You will need your username and password for accessing your database in your cPanel® and your FileZilla client.
Depending on your hosting you may need your username and password for the database.
You will need a copy of your database (see the preceding warning). You can use the chapter on creation of a database and the two previous recipes to EXPORT your data for safety.
- Open your phpMyAdmin and navigate to your database as in previous recipes.
This time we'll start with the GUI method then move to the command line method.
You should be in the TABLE view as follows:
- Scroll down till you find the TABLE you wish to drop. In our case it will be jos_Corn_Syrup.
This is what we would see in our database:
As you can see I have "checked" the box.
- Now scroll down to the bottom and open your drop-down screen as follows:
Be sure you have ONLY selected the table you wish to drop. If you have ANY OTHER table selected it WILL be dropped and will no longer be available.
In this example, we have jos_Corn_Syrup as the only box checked, so we click the Drop command in the above table. MySQL will warn you and give you a chance to verify you DO WANT to drop [erase, delete] the TABLE.
- If you clicked Drop by accident, or if you changed your mind, then click No. In our case however, we want to DROP the tables. Selecting Yes in the lower right-hand side of the screen will drop the tables.
- The phpMyAdmin console tells us that our request has been met and the table is gone.
Now using the command-line method we can accomplish the same thing.
Open your SQL query window at the top menu bar and enter this command:
- Click the Go button in the lower right to commence. You will be prompted to verify you wish to drop that table.
- As we DO wish to, I will select OK. However if I had the wrong table or changed my mind, I could click Cancel and stop the entire operation.
You know you succeeded when you receive this message:
Here you have successfully removed a table.
The commands we executed using the GUI are the same commands a database administrator might use managing the server. These commands tell MySQL to drop, which means permanently erase, the tables, and all the data. It's important to always backup your database before dropping a table in the event you chose the wrong one.