Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using MySQL CLI, how can I remove all data in a given MySQL database without changing any table's structures?

share|improve this question
    
This is in Linux by the way. –  superuser May 29 '12 at 17:48
1  
Have you tried delete * from * just off the top of my head. –  Yitzchak May 29 '12 at 17:52

2 Answers 2

up vote 9 down vote accepted

truncate example:

truncate table friends

– will delete all records from the table and also rebuild the table, thus resetting the auto_increment counter.

share|improve this answer
    
can you truncate an entire database, or do you have to go table by table? –  Thufir Jun 20 at 13:53
1  

It sounds like you want TRUNCATE.

http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.