5

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

3
  • 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
  • That works for a single table, not all – Mawg says reinstate Monica Jan 15 '17 at 10:43
11

truncate example:

truncate table friends

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

3
11

It sounds like you want TRUNCATE.

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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