Reputation: 1557
Is there a SQL command that 'resets' the database in MySQL?
By reset I mean, all rows are deleted and auto increment are reset.
Upvotes: 1
Views: 297
Reputation: 1281
mysqldump -uuser -hhost -p --no-data name_of_database > backup_file_name.sql
The above command will keep the entire structure of your database but without the data. (that's what the --no-data
param does).
Now when you want to reset your database you just:
mysql -uuser -hhost -p < backup_file_name.sql
View the .sql file created to see what its doing. There are a bunch of options you can add to the mysqldump
command.
Enjoy.
Upvotes: 0
Reputation: 21353
You're looking for TRUNCATE
, as in TRUNCATE TABLE mystuff
More info: http://dev.mysql.com/doc/refman/5.0/en/truncate-table.html
Upvotes: 5