Solved

empty a table -  MySQL50

Posted on 2006-07-02
4
396 Views
Last Modified: 2012-05-05
using MySQL 5.0    - - >

what is the easiest way to empty a table?   iow ~  to delete all the data that the table contains...     i'm not talking about dropping the table completely...   rather, just to empty (clear) all the data from it.

is there a way to to this with a "right"-click on the tablename after right-clicking and going to "Edit Table Data" ?    if not,  what is the SQL statement because   DELETE * FROM 'database'.'tablename'   doesn't seem to really empty the table..  cause when i go back to the MySQL Administrator and hit Refresh..  the data in the table still exists.      ??

Thanks.

0
Comment
Question by:lblinc
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 150 total points
Comment Utility
truncate table `schemaName`.`tableName`;

This deletes the data and re-creates the index; this is the fastest and best method
0
 
LVL 35

Expert Comment

by:Raynard7
Comment Utility
Delect * should work - unless you are using transactions; where you will need to commit them.

truncate keeps the table structure but removes all the data within.
0
 
LVL 4

Assisted Solution

by:JeePeeTee
JeePeeTee earned 100 total points
Comment Utility
Truncate isn't transactional and can't be rolled-back when you have referantial constraints to this table and truncate them, your constaints will be removed.

 Delete from table is transactional. You can limit your rollback size by ussing delete from table where limit <your size>
0
 

Author Comment

by:lblinc
Comment Utility
this worked...   thanks.

TRUNCATE `schemaName`.`tableName`;
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Creating and Managing Databases with phpMyAdmin in cPanel.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now