I'm not sure it's query of script who does this, it's like a certain time(you set it) it will reset the database to the time when you just installed it
You can export the database via PHPMyAdmin and check "Add drop tables" (I think its called) and make a quick php-script that executes the resulting .sql file. Then call the php-script every X days/hours/minutes via cron.