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

Removing content from a table

There might be times you wish to remove JUST the data from a table, such as if a spammer inserts names into your mailing database, or you wish to remove all of the data from any table. There are many times this might come in handy.

You will see how to delete a single row of data and delete the entire data set from the table.

In any case, the same warnings apply.

Tip

BACKUP YOUR DATABASE BEFORE YOU START!

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. You can use the recipe to EXPORT your data for safety and backup.

How to do it...

  1. Navigate to your main database menu. You should be here:
    How to do it...

    Once again we will review the GUI method first, then the command-line method.

  2. Locate your table of choice - we'll once again use jos_Corn_Syrup as our table. In this example, we WANT to wipe out the data, but not actually remove the table from the database.
    How to do it...
  3. Choose your table as above then scroll down to the bottom of the screen till you see this screen (opened for the screenshot):
    How to do it...
  4. Choose Empty from the above list. This will prompt you and ask if you are SURE you wish to. Choose Yes in the lower left-corner of the screen to EMPTY (also known as TRUNCATE) the table.

    Once done you will see:

    How to do it...

    This shows that the table was 'emptied' out.

    Command line version of Empty (known as Truncate)

  5. Go back to the top of your phpMyAdmin screen and select the SQL button and enter this command (with the table you want):
    TRUNCATE `jos_Corn_Syrup`;
    

    This will ask you to verify it, and if it's correct, click YES in the lower right-hand corner.

How it works

This command instructs the database to REMOVE the contents by erasing the data.

In reality the "truncate" command that is called 'drops' the entire table and recreates it but without data.

However, it will maintain the structure of the database. This is useful in situations where you are developing a site and want to remove the content before you turn it over to a client, or in situations where the data is not needed but the table setup by the extension is.

See also

http://www.packtpub.com/ offers a title for a more extensive training on phpMyAdmin - http://www.packtpub.com/phpmyadmin-3rd-edition/book

主站蜘蛛池模板: 景洪市| 苍溪县| 临西县| 通州市| 格尔木市| 灵台县| 博兴县| 武定县| 贵南县| 建湖县| 江阴市| 连云港市| 石首市| 余庆县| 望谟县| 胶南市| 朝阳县| 聊城市| 仁布县| 繁昌县| 丰镇市| 白河县| 海南省| 张家港市| 油尖旺区| 阳西县| 伽师县| 高平市| 诸城市| 刚察县| 锦州市| 修水县| 潞西市| 怀宁县| 余姚市| 扶绥县| 清新县| 磐石市| 苍山县| 专栏| 岱山县|