empty a table - MySQL50

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.

lblincAsked:
Who is Participating?
 
Raynard7Commented:
truncate table `schemaName`.`tableName`;

This deletes the data and re-creates the index; this is the fastest and best method
0
 
Raynard7Commented:
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
 
JeePeeTeeCommented:
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
 
lblincAuthor Commented:
this worked...   thanks.

TRUNCATE `schemaName`.`tableName`;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.