官术网_书友最值得收藏!

  • Joomla! 1.5 Cookbook
  • Tom Canavan
  • 612字
  • 2021-04-09 22:58:48

Removing a table from your database

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.

Tip

This is an ADVANCED and DANGEROUS task. Using this command will result in the data in question being permanently removed from your database. BEFORE USING THESE COMMANDS BE SURE AND BACKUP (export) YOUR DATABASE

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.

Getting ready

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.

How to do it...

  1. 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:

    How to do it...
  2. 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:

    How to do it...

    As you can see I have "checked" the box.

  3. Now scroll down to the bottom and open your drop-down screen as follows:
    How to do it...

    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.

  4. 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.
    How to do it...
  5. 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:

    How to do it...
  6. Click the Go button in the lower right to commence. You will be prompted to verify you wish to drop that table.
    How to do it...
  7. 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:

    How to do it...

    Here you have successfully removed a table.

How it works...

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.

主站蜘蛛池模板: 永年县| 竹北市| 太湖县| 孝昌县| 内丘县| 博爱县| 云和县| 吴旗县| 宁陵县| 贡山| 屏南县| 洪雅县| 神池县| 峡江县| 齐河县| 遵义市| 巍山| 东城区| 西乌珠穆沁旗| 青河县| 大邑县| 晋宁县| 江油市| 双牌县| 麻栗坡县| 林周县| 永丰县| 乐安县| 康平县| 宜宾县| 昌图县| 赤水市| 建瓯市| 保定市| 双峰县| 正阳县| 安阳市| 江源县| 且末县| 衡阳市| 大同县|